]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
don't get a count from query
authorEvan Prodromou <evan@prodromou.name>
Tue, 22 Jul 2008 16:31:16 +0000 (12:31 -0400)
committerEvan Prodromou <evan@prodromou.name>
Tue, 22 Jul 2008 16:31:16 +0000 (12:31 -0400)
darcs-hash:20080722163116-84dde-3b17b13022b3d97483e911a99ebd23cc4b8da784.gz

actions/all.php
classes/User.php

index 944fec6d4b7c5958a7157e7a0e86a9157a0c8bb5..ca592a4eb016309bf363906af96e177d4bed8ebe 100644 (file)
@@ -78,20 +78,22 @@ class AllAction extends StreamAction {
                        $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'));
-                       for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
-                               if ($notice->fetch()) {
-                                       $this->show_notice($notice);
-                               } else {
-                                       // shouldn't happen!
-                                       break;
-                               }
+               common_element_start('ul', array('id' => 'notices'));
+               
+               $cnt = 0;
+               
+               while ($notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
+                       $cnt++;
+                       
+                       if ($cnt > NOTICES_PER_PAGE) {
+                               break;
                        }
-                       common_element_end('ul');
+                       
+                       $this->show_notice($notice);
                }
+               common_element_end('ul');
 
                common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
                                                  $page, 'all', array('nickname' => $profile->nickname));
index 7da483653fa09542ea255562c59476a2950b6f33..b6689761eec4159faf62fbd15da775fe02a2f197 100644 (file)
@@ -133,12 +133,12 @@ class User extends DB_DataObject
                
                $notice = new Notice();
                
-               $cnt = $notice->query('SELECT notice.* ' .
-                                                         'FROM notice JOIN subscription on notice.profile_id = subscription.subscribed ' .
-                                                         'WHERE subscription.subscriber = ' . $this->id . ' ' .
-                                                         'ORDER BY created DESC, notice.id DESC ' .
-                                                         'LIMIT ' . $offset . ', ' . $limit);
+               $notice->query('SELECT notice.* ' .
+                                          'FROM notice JOIN subscription on notice.profile_id = subscription.subscribed ' .
+                                          'WHERE subscription.subscriber = ' . $this->id . ' ' .
+                                          'ORDER BY created DESC, notice.id DESC ' .
+                                          'LIMIT ' . $offset . ', ' . $limit);
                
-               return array($cnt, $notice);
+               return $notice;
        }
 }