Since both, Account and Property, belong to User, it should be as easy
as follows:
In your UsersController (app/controllers/users_controller.php), just
do
$this->User->find('all', array('conditions' => array('Users.group_id'
=> 4)));
The method "find('all')" will then return all the associated data of
your User Object.
Kind regards,
Vulinux
On 5 Jul., 06:17, elogic <asymo...@elogicmedia.com.au> wrote:
> Hi All,
>
> I have 3 tables, accounts, users, properties. Within the properties
> add / edit pages I need to populate two select dropdowns with data
> from the accounts table however I am not sure how to go about this.
>
> TABLE INFO (basics)
>
> ACCOUNTS
> id
> first_name
> last_name
>
> USERS
> id
> username
> password
> account_id
> group_id
>
> PROPERTIES
> id
> name
> staff_id
> estate_id
>
> So both staff_id and estate_id need to have selects using the id
> first_name and last_name from ACCOUNTS but staff_id will be where
> group_id in users equals 3 and estate_id = 4.
>
> The basic SQL should be as follows:
>
> SELECT accounts.`id`, accounts.`first_name`, accounts.`last_name` FROM
> accounts, users WHERE accounts.`id` = users.account_id AND
> users.`group_id` = 4
>
> Any ideas how I can go about getting this data within my properties
> controller? I've googled around but I think I am more confused now
> then before.
>
> Thanks
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
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
No comments:
Post a Comment