Wednesday, April 25, 2012

Creating 2 differenz queries in the Model Controller -> How do I access from the View?

Hi

I have in my Model something like this:
---------------------
public function getAllPosts()
{
return $this->find('all', array('contain' => FALSE, 'fields'
=> array('id','title','created',),));
}

public function getSomePosts()
{
return $this->find('all', array('contain' =>
FALSE,'conditions' => array('Post.user_id' => $authorId), 'fields' =>
array('id','title','created',),));
}
---------------------
My Controller shows something like this:
---------------------
public function index()
{
$authorId = $this->Auth->user('id');
$allposts = $this->Post->getAuthorPosts($authorId);
$someposts = $this->Post->getAllPosts();
$this->set(compact('allposts'));
$this->set(compact('someposts'));
}
---------------------

How do I access the two different arrays in the view?

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