Re: Defining more than one hasMany relationship

2008-05-19 Thread Tony Thomas

I tried resetting the array as you describe but the problem persisted.
The only thing that worked was to stop using foreach. I don't get it,
but I stopped trying once I found a solution.

On May 16, 10:58 pm, David Christopher Zentgraf <[EMAIL PROTECTED]>
wrote:
> foreach() does neither modify nor unset the original array unless
> explicitly told to.
> Maybe you're having issues with the array pointer?
>
> http://jp2.php.net/foreach
>
> > foreach has some side effects on the array pointer. Don't rely on
> > the array pointer during or after the foreach without resetting it.
>
> http://jp2.php.net/manual/en/function.reset.php
>
> $numbers = array(1, 2, 3, 4);
>
> foreach ($numbers as $number) {
> $number = null; // does nothing to $numbers
>
> }
>
> print_r(current($numbers)); // prints nothing
>
> reset($numbers);
> print_r(current($numbers)); // prints '1'
>
> print_r($numbers);  // prints 'array([0] => 1, [1] => 2 
> ...)'
>
> On 16 May 2008, at 22:26, Tony Thomas wrote:
>
>
>
> > No. It's simply looping through and echoing the array, but once it
> > does, the contents of the array are no longer available. As soon as I
> > looped through using while(list($key, $value) = each($array) instead
> > of a foreach loop, I was able to loop through it twice to create the
> > second table. Please correct me if I'm wrong, but I presume it's
> > because foreach() operates from a copy of the array, which is then
> > unset after looping through the data. At least, that's what my results
> > suggest. As soon as I switched methods as noted above, the data
> > remained available to loop through again to create a second table from
> > separate data in the array.
>
> > On May 15, 4:20 pm, Dovdimus Prime <[EMAIL PROTECTED]> wrote:
> >> Are you saying that this foreach loop is modifying the contents of
> >> the
> >> array?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-16 Thread David Christopher Zentgraf

foreach() does neither modify nor unset the original array unless  
explicitly told to.
Maybe you're having issues with the array pointer?

http://jp2.php.net/foreach
> foreach has some side effects on the array pointer. Don't rely on  
> the array pointer during or after the foreach without resetting it.

http://jp2.php.net/manual/en/function.reset.php


$numbers = array(1, 2, 3, 4);

foreach ($numbers as $number) {
$number = null; // does nothing to $numbers
}

print_r(current($numbers)); // prints nothing

reset($numbers);
print_r(current($numbers)); // prints '1'

print_r($numbers);  // prints 'array([0] => 1, [1] => 2 
...)'

On 16 May 2008, at 22:26, Tony Thomas wrote:

>
> No. It's simply looping through and echoing the array, but once it
> does, the contents of the array are no longer available. As soon as I
> looped through using while(list($key, $value) = each($array) instead
> of a foreach loop, I was able to loop through it twice to create the
> second table. Please correct me if I'm wrong, but I presume it's
> because foreach() operates from a copy of the array, which is then
> unset after looping through the data. At least, that's what my results
> suggest. As soon as I switched methods as noted above, the data
> remained available to loop through again to create a second table from
> separate data in the array.
>
> On May 15, 4:20 pm, Dovdimus Prime <[EMAIL PROTECTED]> wrote:
>> Are you saying that this foreach loop is modifying the contents of  
>> the
>> array?
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-16 Thread Tony Thomas

No. It's simply looping through and echoing the array, but once it
does, the contents of the array are no longer available. As soon as I
looped through using while(list($key, $value) = each($array) instead
of a foreach loop, I was able to loop through it twice to create the
second table. Please correct me if I'm wrong, but I presume it's
because foreach() operates from a copy of the array, which is then
unset after looping through the data. At least, that's what my results
suggest. As soon as I switched methods as noted above, the data
remained available to loop through again to create a second table from
separate data in the array.

On May 15, 4:20 pm, Dovdimus Prime <[EMAIL PROTECTED]> wrote:
> Are you saying that this foreach loop is modifying the contents of the
> array?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-15 Thread David Zentgraf

If you need to modify the contents of the array, take another close
look at the foreach documentation:

foreach ($arr as &$value) {
$value = $value * 2;
}

On May 16, 5:49 am, Tony Thomas <[EMAIL PROTECTED]> wrote:
> Thanks for all of the help. The tips I got pointed me in the right
> direction. Once I changed my foreach loops to while (list($key,
> $value) = each($patient['Visit'])) and while (list($key, $value) =
> each($patient['M5Symptoms'])) respectively, my data appeared. I
> figured this out once I realized the foreach() operates on a copy of
> the array and list($key, $value) = each($array) doesn't.
>
> http://us2.php.net/foreachhttp://us2.php.net/manual/en/function.list.php
>
> (Links for reference to those who might come upon this in the future.
> Hello from the past.)
>
> On May 15, 2:26 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
>
> > OK, some additional information. (I apologize, because I think this is
> > getting into PHP territory and may not be specifically related to
> > CakePHP.)
>
> > If I place debug($patient) before the first foreach loop (for
> > 'Visit'), I get the arrays as below. If I place it after the foreach
> > loop I get the same "Undefined index" message. How can I preserve that
> > array to reuse it to make a second table?
>
> > On May 15, 12:35 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
>
> > > debug($patient) produces:
>
> > > Array
> > > (
> > >     [Patient] => Array
> > >         (
> > >             [id] => 5007
> > >             [med_hist_id] => 0
> > >             [gender] => M
> > >             [st_of_birth] => [redacted]
> > >             [st_of_res] => [redacted]
> > >             [res_length] => 11 yrs
> > >             [cntry_of_origin] => U.S.
> > >             [dob] => [redacted]
> > >             [siblings] => 2
> > >             [birth_order] => 1
> > >             [mono_before] => N
> > >             [ethnicity] => [redacted]
> > >             [race] => [redacted]
> > >             [contact_by] => email
> > >             [withdrawn] => N
> > >             [kdas] => NKDA
> > >             [mono_dx] => N
> > >         )
>
> > >     [Visit] => Array
> > >         (
> > >             [0] => Array
> > >                 (
> > >                     [id] => 2060
> > >                     [quest_id] =>
> > >                     [patient_id] => 5007
> > >                     [protocol] => Mono 5
> > >                     [vdate] => 4/22/2008
> > >                     [vtmstmp] => 1208840400
> > >                     [week] =>
> > >                     [yr] => 2
> > >                     [number] => 8
> > >                     [notes] => [redacted]
> > >                     [kit] => 0
> > >                     [sev_p] => 0
> > >                     [sev_scr] => 0
> > >                     [sev_pain] =>
> > >                     [modified] => 4/22/2008 2:25:47 PM
> > >                     [created] => 4/22/2008 2:11:39 PM
> > >                 )
> > > //truncated here, but shows the last ten visits as expected
>
> > >         )
>
> > >     [M5Symptom] => Array
> > >         (
> > >             [0] => Array
> > >                 (
> > >                     [id] => 19
> > >                     [patient_id] => 5007
> > >                     [symptom] => Stuffy Nose
> > >                     [start_date] => 12/18/2006
> > >                     [end_date] => 12/21/2006
> > >                     [severity] =>
> > >                     [exported] =>
> > >                     [date_reported] =>
> > >                     [created] =>
> > >                     [modified] =>
> > >                 )
> > > // again truncated by me, but the list of 25 shows up in the array
>
> > >         )
>
> > > )
>
> > > On May 15, 12:23 pm, "[EMAIL PROTECTED]"
>
> > > <[EMAIL PROTECTED]> wrote:
> > > > Hi Tony,
> > > > What do you have in the $patient variable when you debug it?
> > > > debug($patient)
>
> > > > /Martin
>
> > > > On May 15, 5:37 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi All,
>
> > > > > I'm building a CakePHP app for tracking clinic patients, their visits,
> > > > > their symptoms and questionnaire answers. The barrier I've encountered
> > > > > is that each patient has many visits AND many symptoms. I want to view
> > > > > the patient record and their aggregate visits and symptoms.
>
> > > > > I've defined a hasMany relationship in the patient model as such:
>
> > > > > var $hasMany = array(
> > > > >         'Visit' => array(
> > > > >             'order'    => 'Visit.id DESC',
> > > > >             'limit'        => '10'
> > > > >         ),
> > > > >         'M5Symptom' => array(
> > > > >                 'className' => 'M5Symptom',
> > > > >                 'order' => 'M5Symptom.modified DESC',
> > > > >                 'limit' => '25'
> > > > >         )
> > > > >     );
>
> > > > > In the patient view I get the relevant patient data, and the
> > > > > corresponding list of visits, but I get the message, "Undefined
> > > > > index:  M5Symptom" for li

Re: Defining more than one hasMany relationship

2008-05-15 Thread Tony Thomas

Thanks for all of the help. The tips I got pointed me in the right
direction. Once I changed my foreach loops to while (list($key,
$value) = each($patient['Visit'])) and while (list($key, $value) =
each($patient['M5Symptoms'])) respectively, my data appeared. I
figured this out once I realized the foreach() operates on a copy of
the array and list($key, $value) = each($array) doesn't.

http://us2.php.net/foreach
http://us2.php.net/manual/en/function.list.php

(Links for reference to those who might come upon this in the future.
Hello from the past.)

On May 15, 2:26 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
> OK, some additional information. (I apologize, because I think this is
> getting into PHP territory and may not be specifically related to
> CakePHP.)
>
> If I place debug($patient) before the first foreach loop (for
> 'Visit'), I get the arrays as below. If I place it after the foreach
> loop I get the same "Undefined index" message. How can I preserve that
> array to reuse it to make a second table?
>
> On May 15, 12:35 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
>
> > debug($patient) produces:
>
> > Array
> > (
> > [Patient] => Array
> > (
> > [id] => 5007
> > [med_hist_id] => 0
> > [gender] => M
> > [st_of_birth] => [redacted]
> > [st_of_res] => [redacted]
> > [res_length] => 11 yrs
> > [cntry_of_origin] => U.S.
> > [dob] => [redacted]
> > [siblings] => 2
> > [birth_order] => 1
> > [mono_before] => N
> > [ethnicity] => [redacted]
> > [race] => [redacted]
> > [contact_by] => email
> > [withdrawn] => N
> > [kdas] => NKDA
> > [mono_dx] => N
> > )
>
> > [Visit] => Array
> > (
> > [0] => Array
> > (
> > [id] => 2060
> > [quest_id] =>
> > [patient_id] => 5007
> > [protocol] => Mono 5
> > [vdate] => 4/22/2008
> > [vtmstmp] => 1208840400
> > [week] =>
> > [yr] => 2
> > [number] => 8
> > [notes] => [redacted]
> > [kit] => 0
> > [sev_p] => 0
> > [sev_scr] => 0
> > [sev_pain] =>
> > [modified] => 4/22/2008 2:25:47 PM
> > [created] => 4/22/2008 2:11:39 PM
> > )
> > //truncated here, but shows the last ten visits as expected
>
> > )
>
> > [M5Symptom] => Array
> > (
> > [0] => Array
> > (
> > [id] => 19
> > [patient_id] => 5007
> > [symptom] => Stuffy Nose
> > [start_date] => 12/18/2006
> > [end_date] => 12/21/2006
> > [severity] =>
> > [exported] =>
> > [date_reported] =>
> > [created] =>
> > [modified] =>
> > )
> > // again truncated by me, but the list of 25 shows up in the array
>
> > )
>
> > )
>
> > On May 15, 12:23 pm, "[EMAIL PROTECTED]"
>
> > <[EMAIL PROTECTED]> wrote:
> > > Hi Tony,
> > > What do you have in the $patient variable when you debug it?
> > > debug($patient)
>
> > > /Martin
>
> > > On May 15, 5:37 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
>
> > > > Hi All,
>
> > > > I'm building a CakePHP app for tracking clinic patients, their visits,
> > > > their symptoms and questionnaire answers. The barrier I've encountered
> > > > is that each patient has many visits AND many symptoms. I want to view
> > > > the patient record and their aggregate visits and symptoms.
>
> > > > I've defined a hasMany relationship in the patient model as such:
>
> > > > var $hasMany = array(
> > > > 'Visit' => array(
> > > > 'order'=> 'Visit.id DESC',
> > > > 'limit'=> '10'
> > > > ),
> > > > 'M5Symptom' => array(
> > > > 'className' => 'M5Symptom',
> > > > 'order' => 'M5Symptom.modified DESC',
> > > > 'limit' => '25'
> > > > )
> > > > );
>
> > > > In the patient view I get the relevant patient data, and the
> > > > corresponding list of visits, but I get the message, "Undefined
> > > > index:  M5Symptom" for listing the symptoms. As far as I can tell the
> > > > model is correct, because the query for the patient view finds and
> > > > retrieves a list of 25 symptom records exactly as specified in the
> > > > model. From that I take that the model and controller must be working
> > > > as expected. Otherwise the query wouldn't be right and/or it wouldn't
> > > > retrieve the pertinent records. The query that results is EXACTLY what
> > > > I w

Re: Defining more than one hasMany relationship

2008-05-15 Thread Dovdimus Prime

Are you saying that this foreach loop is modifying the contents of the
array?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-15 Thread Tony Thomas

OK, some additional information. (I apologize, because I think this is
getting into PHP territory and may not be specifically related to
CakePHP.)

If I place debug($patient) before the first foreach loop (for
'Visit'), I get the arrays as below. If I place it after the foreach
loop I get the same "Undefined index" message. How can I preserve that
array to reuse it to make a second table?

On May 15, 12:35 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
> debug($patient) produces:
>
> Array
> (
> [Patient] => Array
> (
> [id] => 5007
> [med_hist_id] => 0
> [gender] => M
> [st_of_birth] => [redacted]
> [st_of_res] => [redacted]
> [res_length] => 11 yrs
> [cntry_of_origin] => U.S.
> [dob] => [redacted]
> [siblings] => 2
> [birth_order] => 1
> [mono_before] => N
> [ethnicity] => [redacted]
> [race] => [redacted]
> [contact_by] => email
> [withdrawn] => N
> [kdas] => NKDA
> [mono_dx] => N
> )
>
> [Visit] => Array
> (
> [0] => Array
> (
> [id] => 2060
> [quest_id] =>
> [patient_id] => 5007
> [protocol] => Mono 5
> [vdate] => 4/22/2008
> [vtmstmp] => 1208840400
> [week] =>
> [yr] => 2
> [number] => 8
> [notes] => [redacted]
> [kit] => 0
> [sev_p] => 0
> [sev_scr] => 0
> [sev_pain] =>
> [modified] => 4/22/2008 2:25:47 PM
> [created] => 4/22/2008 2:11:39 PM
> )
> //truncated here, but shows the last ten visits as expected
>
> )
>
> [M5Symptom] => Array
> (
> [0] => Array
> (
> [id] => 19
> [patient_id] => 5007
> [symptom] => Stuffy Nose
> [start_date] => 12/18/2006
> [end_date] => 12/21/2006
> [severity] =>
> [exported] =>
> [date_reported] =>
> [created] =>
> [modified] =>
> )
> // again truncated by me, but the list of 25 shows up in the array
>
> )
>
> )
>
> On May 15, 12:23 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Hi Tony,
> > What do you have in the $patient variable when you debug it?
> > debug($patient)
>
> > /Martin
>
> > On May 15, 5:37 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
>
> > > Hi All,
>
> > > I'm building a CakePHP app for tracking clinic patients, their visits,
> > > their symptoms and questionnaire answers. The barrier I've encountered
> > > is that each patient has many visits AND many symptoms. I want to view
> > > the patient record and their aggregate visits and symptoms.
>
> > > I've defined a hasMany relationship in the patient model as such:
>
> > > var $hasMany = array(
> > > 'Visit' => array(
> > > 'order'=> 'Visit.id DESC',
> > > 'limit'=> '10'
> > > ),
> > > 'M5Symptom' => array(
> > > 'className' => 'M5Symptom',
> > > 'order' => 'M5Symptom.modified DESC',
> > > 'limit' => '25'
> > > )
> > > );
>
> > > In the patient view I get the relevant patient data, and the
> > > corresponding list of visits, but I get the message, "Undefined
> > > index:  M5Symptom" for listing the symptoms. As far as I can tell the
> > > model is correct, because the query for the patient view finds and
> > > retrieves a list of 25 symptom records exactly as specified in the
> > > model. From that I take that the model and controller must be working
> > > as expected. Otherwise the query wouldn't be right and/or it wouldn't
> > > retrieve the pertinent records. The query that results is EXACTLY what
> > > I want.
>
> > > That leads me to believe the problem must be in the view.
>
> > > Here's the view function in the patient controller:
>
> > > function view($id = null) {
>
> > > $this->Patient->id = $id;
> > > $this->set('patient', $this->Patient->read());
>
> > > }
>
> > > Everything works right up until I try to list the symptoms. Here's the
> > > code for listing symptoms in the view:
>
> > > echo $html->tableHeaders(array('Symptom','Start Date','End Date',
> > > 'Severity'));
>
> > > foreach ($patient['M5Symptom'] as $symptom) {
>
> > > echo $html->tableCells(
>
> > > array($symptom['symptom'],
> > >   $symptom['start_date'],
> > >   $symptom['end_date'],
> > >   $symptom['severity'],
> > > )
> > > );
>
> > > }

Re: Defining more than one hasMany relationship

2008-05-15 Thread Tony Thomas

debug($patient) produces:

Array
(
[Patient] => Array
(
[id] => 5007
[med_hist_id] => 0
[gender] => M
[st_of_birth] => [redacted]
[st_of_res] => [redacted]
[res_length] => 11 yrs
[cntry_of_origin] => U.S.
[dob] => [redacted]
[siblings] => 2
[birth_order] => 1
[mono_before] => N
[ethnicity] => [redacted]
[race] => [redacted]
[contact_by] => email
[withdrawn] => N
[kdas] => NKDA
[mono_dx] => N
)

[Visit] => Array
(
[0] => Array
(
[id] => 2060
[quest_id] =>
[patient_id] => 5007
[protocol] => Mono 5
[vdate] => 4/22/2008
[vtmstmp] => 1208840400
[week] =>
[yr] => 2
[number] => 8
[notes] => [redacted]
[kit] => 0
[sev_p] => 0
[sev_scr] => 0
[sev_pain] =>
[modified] => 4/22/2008 2:25:47 PM
[created] => 4/22/2008 2:11:39 PM
)
//truncated here, but shows the last ten visits as expected

)

[M5Symptom] => Array
(
[0] => Array
(
[id] => 19
[patient_id] => 5007
[symptom] => Stuffy Nose
[start_date] => 12/18/2006
[end_date] => 12/21/2006
[severity] =>
[exported] =>
[date_reported] =>
[created] =>
[modified] =>
)
// again truncated by me, but the list of 25 shows up in the array

)

)

On May 15, 12:23 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi Tony,
> What do you have in the $patient variable when you debug it?
> debug($patient)
>
> /Martin
>
> On May 15, 5:37 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
>
> > Hi All,
>
> > I'm building a CakePHP app for tracking clinic patients, their visits,
> > their symptoms and questionnaire answers. The barrier I've encountered
> > is that each patient has many visits AND many symptoms. I want to view
> > the patient record and their aggregate visits and symptoms.
>
> > I've defined a hasMany relationship in the patient model as such:
>
> > var $hasMany = array(
> > 'Visit' => array(
> > 'order'=> 'Visit.id DESC',
> > 'limit'=> '10'
> > ),
> > 'M5Symptom' => array(
> > 'className' => 'M5Symptom',
> > 'order' => 'M5Symptom.modified DESC',
> > 'limit' => '25'
> > )
> > );
>
> > In the patient view I get the relevant patient data, and the
> > corresponding list of visits, but I get the message, "Undefined
> > index:  M5Symptom" for listing the symptoms. As far as I can tell the
> > model is correct, because the query for the patient view finds and
> > retrieves a list of 25 symptom records exactly as specified in the
> > model. From that I take that the model and controller must be working
> > as expected. Otherwise the query wouldn't be right and/or it wouldn't
> > retrieve the pertinent records. The query that results is EXACTLY what
> > I want.
>
> > That leads me to believe the problem must be in the view.
>
> > Here's the view function in the patient controller:
>
> > function view($id = null) {
>
> > $this->Patient->id = $id;
> > $this->set('patient', $this->Patient->read());
>
> > }
>
> > Everything works right up until I try to list the symptoms. Here's the
> > code for listing symptoms in the view:
>
> > echo $html->tableHeaders(array('Symptom','Start Date','End Date',
> > 'Severity'));
>
> > foreach ($patient['M5Symptom'] as $symptom) {
>
> > echo $html->tableCells(
>
> > array($symptom['symptom'],
> >   $symptom['start_date'],
> >   $symptom['end_date'],
> >   $symptom['severity'],
> > )
> > );
>
> > }
>
> > I've looked at all of this over and over and I just can't find out why
> > 'M5Symptom' is undefined. Just above this, 'Visit' lists recent visit
> > dates for me with the exact same logic in place.
>
> > Am I wrong in assuming I can define more than one hasMany? If so, why
> > is the correct query generated? I'm hoping another set of eyes will
> > find what I'm missing. Sleeping on it didn't help.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more opti

Re: Defining more than one hasMany relationship

2008-05-15 Thread [EMAIL PROTECTED]

Hi Tony,
What do you have in the $patient variable when you debug it?
debug($patient)

/Martin


On May 15, 5:37 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I'm building a CakePHP app for tracking clinic patients, their visits,
> their symptoms and questionnaire answers. The barrier I've encountered
> is that each patient has many visits AND many symptoms. I want to view
> the patient record and their aggregate visits and symptoms.
>
> I've defined a hasMany relationship in the patient model as such:
>
> var $hasMany = array(
>         'Visit' => array(
>             'order'    => 'Visit.id DESC',
>             'limit'        => '10'
>         ),
>         'M5Symptom' => array(
>                 'className' => 'M5Symptom',
>                 'order' => 'M5Symptom.modified DESC',
>                 'limit' => '25'
>         )
>     );
>
> In the patient view I get the relevant patient data, and the
> corresponding list of visits, but I get the message, "Undefined
> index:  M5Symptom" for listing the symptoms. As far as I can tell the
> model is correct, because the query for the patient view finds and
> retrieves a list of 25 symptom records exactly as specified in the
> model. From that I take that the model and controller must be working
> as expected. Otherwise the query wouldn't be right and/or it wouldn't
> retrieve the pertinent records. The query that results is EXACTLY what
> I want.
>
> That leads me to believe the problem must be in the view.
>
> Here's the view function in the patient controller:
>
> function view($id = null) {
>
>                 $this->Patient->id = $id;
>                 $this->set('patient', $this->Patient->read());
>
>         }
>
> Everything works right up until I try to list the symptoms. Here's the
> code for listing symptoms in the view:
>
> echo $html->tableHeaders(array('Symptom','Start Date','End Date',
> 'Severity'));
>
> foreach ($patient['M5Symptom'] as $symptom) {
>
>         echo $html->tableCells(
>
>         array($symptom['symptom'],
>               $symptom['start_date'],
>               $symptom['end_date'],
>               $symptom['severity'],
>         )
>         );
>
> }
>
> I've looked at all of this over and over and I just can't find out why
> 'M5Symptom' is undefined. Just above this, 'Visit' lists recent visit
> dates for me with the exact same logic in place.
>
> Am I wrong in assuming I can define more than one hasMany? If so, why
> is the correct query generated? I'm hoping another set of eyes will
> find what I'm missing. Sleeping on it didn't help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-15 Thread Tony Thomas

print_r($patient['M5Symptom']) results in the expected list of
symptoms:

Array
(
[0] => Array
(
[id] => 19
[patient_id] => 5007
[symptom] => Stuffy Nose
[start_date] => 12/18/2006
[end_date] => 12/21/2006
[severity] =>
[exported] =>
[date_reported] =>
[created] =>
[modified] =>
)

//etc. for the full list of 25 most recent symptoms

)


On May 15, 12:00 pm, Dovdimus Prime <[EMAIL PROTECTED]> wrote:
> Yep: 'undefined index' definitely means you're not referencing your
> part of the patients array properly. The problem may well be nothing
> to do with the associations in your model.
>
> Use print_r to look at the array you're passing into the view.
>
> David

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-15 Thread Dovdimus Prime

Yep: 'undefined index' definitely means you're not referencing your
part of the patients array properly. The problem may well be nothing
to do with the associations in your model.

Use print_r to look at the array you're passing into the view.

David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-15 Thread Dovdimus Prime

Have you checked that:

$patient['M5Symptom']

is the correct way of referencing the array of symptoms within the
patients array? I've not checked, but often Cake puts model results in
an array like this:

Patient array:

array([0] => array('M5Symptom' => array of all the symptoms...

What I mean is, have you tried $patient[0]['M5Symptom'] to get the
list of symptoms?

I often find I need to use print_r($nameofmyarray) in the view to read
the array in order to work out how to reference particular parts of
the array.

HTH

David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---