Browse Source

Fixed validation warnings for CakePHP for single and multi-queries. #1406

Steve Smith 10 years ago
parent
commit
1fb88204c6
1 changed files with 5 additions and 1 deletions
  1. 5 1
      frameworks/PHP/cakephp/app/Controller/WorldController.php

+ 5 - 1
frameworks/PHP/cakephp/app/Controller/WorldController.php

@@ -37,8 +37,12 @@ class WorldController extends AppController {
       // Retrieve a model by ID
       // http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#find
       $world = $this->World->find('first', array('conditions' => array('id' => $id)));
+      // Cast numbers to int so they don't get quoted in JSON
+      $result = $world['World'];
+      $result['id'] = (int) $result['id'];
+      $result['randomNumber'] = (int) $result['randomNumber'];
       // Store result in array.
-      $arr[] = array("id" => $world['World']['id'], "randomNumber" => $world['World']['randomNumber']);
+      $arr[] = array("id" => $result['id'], "randomNumber" => $result['randomNumber']);
     }
 
     # Return either one object or a json list