Sunday, February 26, 2012

Cakephp Foreach when using Joins

Hey guys, I am having issues while using foreach...

This is what I have in my Updates Controller.... and its working fine.
While outputting the data in views/updates/index, I am using foreach
and I am not being echo out the users name from users table.

Can anyone help me with the foreach statement to echo out the users
name and other column values?

$options['joins'] = array(
array('table' => 'follows',
'alias' => 'Follow',
'type' => 'inner',
'conditions' => array('Update.user_id = Follow.followed_to')
),
array('table' => 'users',
'alias' => 'User',
'type' => 'inner',
'conditions' => array('Follow.followed_by = User.id')
));
$options['conditions'] = array('User.id='.$this->Session-
>read('Auth.User.id'));
$this->set('updates', $this->Update-
>find('all',array('Update.user_id='.$this->Session-
>read('Auth.User.id')), $options));

--
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: