CakePHP: accessing data from query in view

CixPriregen

New Member
I have a hasMany relationship set up. User hasMany Projects. In my users controller in the profile view I can see the projects being returned for that user in the SQL dump.I want to display each project in my profile view for that user. So I have set up a association between user and projects. User hasMany projects. I have created a profile action in the users controller with the associated profile view. When I navigate to the profile view of one of the users with, I can see that it is querying for the projects in the SQL dump.This is the SQL dump with the correct userid:\[code\]SELECT `Project`.`id`, `Project`.`title`, `Project`.`created`, `Project`.`website`, `Project`.`language_id`, `Project`.`user_id`, `Project`.`description`, `Project`.`tags`, `Project`.`creator_id` FROM `projects` AS `Project` WHERE `Project`.`user_id` = (5)\[/code\]How can I use the data from this query?Project Model \[code\]var $belongsTo = array( 'User' => array( 'className' => 'User', 'foreignKey' => 'user_id', 'counterCache' => 'num_of_projects' ), 'Language' ); ?>\[/code\]User Model\[code\] var $hasMany = array('Project' => array('className' => 'Project', 'conditions' => '', 'order' => '', 'limit' => '', 'foreignKey' => 'user_id', 'dependent' => true, 'exclusive' => false, 'finderQuery' => '', 'fields' => '', 'offset' => '', 'counterQuery' => '' ) );\[/code\]User_Controller's profile action\[code\]function profile($id = null) { $this->User->id = $id; $this->set('user', $this->User->read());}\[/code\]
 
Back
Top