Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8994

Re: comparing arrays

Message-ID <7617460.I37VCjhOAZ@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-04-07 17:13 +0200
Subject Re: comparing arrays
Newsgroups comp.lang.php
References <kjrlk6$8es$1@speranza.aioe.org> <kjrp0m$ote$1@dont-email.me> <kjru58$19d$1@speranza.aioe.org> <kjrv05$5lq$2@inn-newsserver.rz.tu-ilmenau.de>

Show all headers | View raw


Frank Steinmetzger wrote:

> bill wrote:
>> On 4/7/2013 8:34 AM, Jerry Stuckle wrote:
>>> On 4/7/2013 7:34 AM, bill wrote:
>>>> I need to see if a patient has appointments with a psychotherapist
>>>> and a physician on the same day.
>>>>
>>>> I request the schedule of each therapist and each physician as
>>>> arrays of arrays:
>>>> time, patient_number, duration (note, the therapist/physician
>>>> id is not in the array)
>>>> They are non-associative arrays (numeric keys)
>>>> I might have 1..n physicians and 1..n therapists
>>>> I can generate arrays of physicians and arrays of therapists
>>>> […]
>>>>
>>> Does the information come from a SQL database?  If so, I'd do it
>>> in SQL.
>> 
>> Yes it does, 3 tables: users (therapist/physician), pt_info,
>> schedule.
>> 
>> A little more of a hint please.
> 
> You select two different appointments that have the same date:
> 
> SELECT s1.patient_number AS pn, s1.time AS t1, s2.time AS t2,
> s1.duration AS d1, s2.duration AS d2
> FROM schedule s1, schedule s2
> WHERE s1.time=s2.time AND s1.time=<today's date>
> AND s1.patient_number=s2.patient_number
> AND s1.patient_number=<ID of patient of interest>
> AND s1.id!=s2.id
> AND s1.doctor_number!=s2.doctor_number

Please don't.  If each schedule table has as little as 100 records, there 
will be 10'000 result records to filter from.  Read on JOIN to avoid 
Cartesian products like this.

> Of course, those times don't work that way, b/c they have date *and* time,
> and you want to deal with date only. I'm not into advanced SQL,

Apparently you are not into SQL, or relational databases for that matter, at 
all. 

> perhaps there is an SQL function to only extract and use the date part.

QED.
 
> You then would need to PHP-fiddle the time and duration together for only
> those appointments that are today in a nested for-loop.

No.  Apparently you are also not into PHP.

Please refrain from suggesting “solutions” in areas where you do not have a 
(minimum) clue.  TIA.


PointedEars
-- 
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
  -- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

comparing arrays bill <william@TechServSys.com> - 2013-04-07 07:34 -0400
  Re: comparing arrays Jerry Stuckle <jstucklex@attglobal.net> - 2013-04-07 08:34 -0400
    Re: comparing arrays bill <william@TechServSys.com> - 2013-04-07 10:00 -0400
      Re: comparing arrays Frank Steinmetzger <frank.steinmetzger@stud.tu-ilmenau.de> - 2013-04-07 16:14 +0200
        Re: comparing arrays Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-07 17:13 +0200
        Re: comparing arrays bill <william@TechServSys.com> - 2013-04-07 11:34 -0400
          Re: comparing arrays Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-07 21:33 +0200
      Re: comparing arrays The Natural Philosopher <tnp@invalid.invalid> - 2013-04-07 16:01 +0100
        Re: comparing arrays Frank Steinmetzger <frank.steinmetzger@stud.tu-ilmenau.de> - 2013-04-07 20:22 +0200
      Re: comparing arrays Jerry Stuckle <jstucklex@attglobal.net> - 2013-04-07 14:18 -0400
  Re: comparing arrays Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-07 15:37 +0200
    Re: comparing arrays bill <william@TechServSys.com> - 2013-04-07 09:59 -0400
      Re: comparing arrays Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-07 17:14 +0200
  Re: comparing arrays The Natural Philosopher <tnp@invalid.invalid> - 2013-04-07 15:59 +0100

csiph-web