Tuesday, February 23, 2010

Re: how to adress specific data from related models?

Turn on debugging (Configure::write('debug', 2); within /app/config/core.php) and type debug($this->data); (and perhaps die; as well) at the top of your controller function and you'll see exactly what's been posted. Then it's a case of accessing the right part of the array to get the values you want.

Jeremy Burns
jeremyburns@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 23 Feb 2010, at 08:41, mivogt-LU wrote:

> I am newbie to cakephp and after some looking up in books and google I
> need still help to start with cake...
>
> I try to do my first application and am using several models linked to
> tables and with relations between the models.
>
> i.e.
> model lodgings with the numberOfBeds
> and a
> model bookingpositions with lodging_id and amountOfPersons
>
> If I want to check if there are enough beds in the room for the
> persons,
> i need to get the amountofbeds attribute for the lodging with the id
> lodging_id
> to pass the numberofbeds to my own validationfunction with the
> amountOfPersons to check and validate or pass an errormessage.
>
> Sadly I have no idea how to access the data posted from the model or
> how to access the data of the linked model lodgings.
>
> Could someone please help me with a bit of code?
>
> I tried a print_r($data) and all the form values from the one model
> are inside tha arary.
> If i trie to access a value out of the array I fail to name the
> index.
> $data[amountofpersons] do not work and $data['amountofpersons'] do not
> work, too.
>
> And absolute no idea hot to get the numberofbeds from the linked model
> sql might look like selct nubmerbofbeds from lodgings where id =
> bookingpositions.lodging_id
> but how to do it right with cake?????
>
> Any help realy welcome!
> Thanks in advance
>
> Michael
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> 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
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: