don't get a count from query

darcs-hash:20080722163116-84dde-3b17b13022b3d97483e911a99ebd23cc4b8da784.gz
This commit is contained in:
Evan Prodromou 2008-07-22 12:31:16 -04:00
parent 9515303b14
commit 42ac47915b
2 changed files with 19 additions and 17 deletions

View File

@ -78,20 +78,22 @@ class AllAction extends StreamAction {
$page = 1; $page = 1;
} }
list($cnt, $notice) = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
if ($cnt > 0) {
common_element_start('ul', array('id' => 'notices')); common_element_start('ul', array('id' => 'notices'));
for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
if ($notice->fetch()) { $cnt = 0;
$this->show_notice($notice);
} else { while ($notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
// shouldn't happen! $cnt++;
if ($cnt > NOTICES_PER_PAGE) {
break; break;
} }
$this->show_notice($notice);
} }
common_element_end('ul'); common_element_end('ul');
}
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
$page, 'all', array('nickname' => $profile->nickname)); $page, 'all', array('nickname' => $profile->nickname));

View File

@ -133,12 +133,12 @@ class User extends DB_DataObject
$notice = new Notice(); $notice = new Notice();
$cnt = $notice->query('SELECT notice.* ' . $notice->query('SELECT notice.* ' .
'FROM notice JOIN subscription on notice.profile_id = subscription.subscribed ' . 'FROM notice JOIN subscription on notice.profile_id = subscription.subscribed ' .
'WHERE subscription.subscriber = ' . $this->id . ' ' . 'WHERE subscription.subscriber = ' . $this->id . ' ' .
'ORDER BY created DESC, notice.id DESC ' . 'ORDER BY created DESC, notice.id DESC ' .
'LIMIT ' . $offset . ', ' . $limit); 'LIMIT ' . $offset . ', ' . $limit);
return array($cnt, $notice); return $notice;
} }
} }