Tuesday, February 23, 2010

how to adress specific data from related models?

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

No comments: