The data returned in the following format:
in the controller
[User] => Array
(
[first_name] => Vikas
[last_name] => tyagi
[phone_no] => 0234
[mobile_no] => 0
[location_id] => 1
[state_id] => 2
)
and i have table locations
field id location_name
value 1 chandigarh
i want to fire that query
select location_name from locations where location_id=1;
how can i do it in cake php
thanks in advance
Two ways, one is simpler but more tedious, the other requires a setup but easier to use in the future.
First way:
Second way:
Setup a belongsTo relationship in your User model and hasOne in your Location model
This way, whenever you do a ->find() from your user model, the Location info would also be returned.
http://book.cakephp.org/1.3/view/1041/hasOne