Browse Source

fix fortunes test, #2

ikkez 11 years ago
parent
commit
2ec6396d17
2 changed files with 5 additions and 4 deletions
  1. 2 1
      php-fatfree/index.php
  2. 3 3
      php-fatfree/ui/fortune.html

+ 2 - 1
php-fatfree/index.php

@@ -87,7 +87,8 @@ $f3->route('GET /fortune', function ($f3) {
     $db = new \DB\SQL($dbc[0],$dbc[1],$dbc[2],array( \PDO::ATTR_PERSISTENT => TRUE ));
     $db = new \DB\SQL($dbc[0],$dbc[1],$dbc[2],array( \PDO::ATTR_PERSISTENT => TRUE ));
     $result = $db->exec('SELECT id, message FROM Fortune');
     $result = $db->exec('SELECT id, message FROM Fortune');
     $result[] = 'Additional fortune added at request time.';
     $result[] = 'Additional fortune added at request time.';
-    asort($result);
+    $mtx = \Matrix::instance();
+    $mtx->sort($result,'message');
     $f3->set('result',$result);
     $f3->set('result',$result);
     echo \Template::instance()->render('fortune.html');
     echo \Template::instance()->render('fortune.html');
 });
 });

+ 3 - 3
php-fatfree/ui/fortune.html

@@ -9,10 +9,10 @@
             <th>id</th>
             <th>id</th>
             <th>message</th>
             <th>message</th>
         </tr>
         </tr>
-        <repeat group="{{@result}}" key="{{@id}}" value="{{@fortune}}">
+        <repeat group="{{@result}}" value="{{@fortune}}">
             <tr>
             <tr>
-                <td>{{@id}}</td>
-                <td>{{@fortune}}</td>
+                <td>{{@fortune.id}}</td>
+                <td>{{@fortune.message}}</td>
             </tr>
             </tr>
         </repeat>
         </repeat>
     </table>
     </table>