I have 2 models:
Users
Counties
I have set up User model with HABTM relationship, because a user has
one or more counties with their account
tables look like this
users
- id
- username
- password
- email
counties
- id
- county
users_counties
- user_id
- county_id
I need to generate a key=>val list of a user's counties to populate
various select lists, I can't seem to make this work by just giving the
relationships in the models, the SQL would look like:
select County.id, County.count from counties as County INNER JOIN
users_counties on County.id = users_counties.county_id where
users_counties.user_id = ?
I am needing to set the value of user_id by getting if from my Session
Right now I have resorted to:
$u = $this->Session->read('User');
$this->User->id = $u['User']['id'];
$data = $this->User->read();
Then I loop through $data['County'] and do my own select tag.
I'm hoping there is an easier way, any help is appreciated.
Thanks,
Brian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---