10-13-2009, 05:50 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: Jan 2009
Posts: 40
Thanks: 10
|
Status updates
Hey, I am using CakePHP to make a website. I have a bit of a problem. I am wanting to get status updates for each of my friends (Stored in a database table) but i only want to get 20 status updates maximum overall.
It's probably quite easy but I cannot work it out. Well I do have it done at the moment but its not as good as i want it.
What I have at the moment is:
PHP Code:
$friends = $this->Friends->Find('all', array('conditions'=>array('user_id'=>$this->Auth->user('id'), 'status'=>'1'), 'fields'=>array('user_friend')));
foreach ($friends as $freind)
{
$status[] = $this->Status->find('all', array('limit'=>5, 'conditions'=>array('author'=>$freind['Friends']['user_friend'])));
}
if ($status)
{
foreach ($status as $statuses)
{
foreach ($statuses as $statuses1)
{
$statuses2[] = $statuses1;
}
}
$statuses2 = Set::sort($statuses2, '{n}.Status.date', 'desc');
$statuses2 = array_slice($statuses2, 0, 20);
if ($statuses2)
{
$this->set('statusesData', $statuses2);
}
|
|
|
|