Browse Source

add new fortune and add sort fortune

Hendrawan Kuncoro 12 years ago
parent
commit
02df0947fa
1 changed files with 18 additions and 2 deletions
  1. 18 2
      php-senthot/app/Lib/Action/BenchAction.class.php

+ 18 - 2
php-senthot/app/Lib/Action/BenchAction.class.php

@@ -1,5 +1,4 @@
 <?php
 <?php
-// This class automatically generated by the System, for testing purposes
 class BenchAction extends Action {
 class BenchAction extends Action {
 
 
    public function rawjson() {
    public function rawjson() {
@@ -30,7 +29,24 @@ class BenchAction extends Action {
    }
    }
    public function rawfortunes() {
    public function rawfortunes() {
       $Fortunes = M('Fortune');
       $Fortunes = M('Fortune');
-      $this->data = $Fortunes->select();
+      $data = $Fortunes->select();
+
+      $data[] = array(
+            'id' => 0,
+            'message' => 'Additional fortune added at request time.'
+        );
+
+      usort($data, function($left, $right) {
+         if ($left['message'] === $right['message']) {
+            return 0;
+         } else if ($left['message'] > $right['message']) {
+            return 1;
+         } else {
+            return -1;
+         }
+      });
+
+      $this->data = $data;
       $this->display();
       $this->display();
    }
    }
 }
 }