hi Jeremy
I created relationship as u said and now select list displayed user's id
list.
I joined two tables called Album and User
"Album" has one "User" and "User" has many "Albums"
Album table has a field called "user_id" and it is foreign key of user
table,
here are my codes
::::::User Model:::
var $hasMany = array('Album');
::::::Album Model:::::::::
var $hasOne = array('User'=> array(
'className' => 'User',
'foreignKey' => 'user_id',
'dependent'=> false
));
:::::::Album controller::::::::::::::
$users = $this->Album->User->find('list');
$this->set(compact('users'));
:::::::::::view:::::::::::::::::::
echo $form->input('user_id', array('label' => 'Select User'));
when I run the code, it gives sql error like this,
SELECT `Album`.`id`, `Album`.`album_name`, `Album`.`sub_directory`,
`Album`.`create_date`, `Album`.`last_modified_date`, `Album`.`music_id`,
`Album`.`album_category`, `Album`.`album_description`, `Album`.`user_id`,
`Album`.`size`, `User`.`id`, `User`.`user_name`, `User`.`user_password`,
`User`.`user_email`, `User`.`user_role`, `User`.`status`,
`User`.`temp_password` FROM `albums` AS `Album` LEFT JOIN `users` AS `User`
ON (`User`.`user_id` = `Album`.`id`) WHERE 1 = 1
error occurred due to above highlighted sql part , It should be like this
(`Album`.`user_id` = `User`.`id`)
so where should i change the code to fix the error???
I kindly ask for quick response!
Ganganath Hettiarachchi
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php