Browse Source

Fixed validation warnings for single and multi-queries. Part of #1405

Steve Smith 10 years ago
parent
commit
fa7beeb0cb
1 changed files with 6 additions and 1 deletions
  1. 6 1
      frameworks/PHP/Yii2/app/controllers/SiteController.php

+ 6 - 1
frameworks/PHP/Yii2/app/controllers/SiteController.php

@@ -28,6 +28,8 @@ class SiteController extends Controller
 
 
         if ($queries == 1) {
         if ($queries == 1) {
             $arr = $statement->bindValue(':id',mt_rand(1, 10000))->queryOne();
             $arr = $statement->bindValue(':id',mt_rand(1, 10000))->queryOne();
+            $arr['id'] = (int) $arr['id'];
+            $arr['randomNumber'] = (int) $arr['randomNumber'];
         } else {
         } else {
             if ($queries > 500) $queries = 500;
             if ($queries > 500) $queries = 500;
             elseif ($queries <= 0 ) $queries = 1;
             elseif ($queries <= 0 ) $queries = 1;
@@ -36,7 +38,10 @@ class SiteController extends Controller
             // For each query, store the result set values in the response array
             // For each query, store the result set values in the response array
             while (0 < $queries--) {
             while (0 < $queries--) {
                 // Store result in array.
                 // Store result in array.
-                $arr[] = $statement->bindValue(':id',mt_rand(1, 10000))->queryOne();
+                $result = $statement->bindValue(':id',mt_rand(1, 10000))->queryOne();
+                $result['id'] = (int) $result['id'];
+                $result['randomNumber'] = (int) $result['randomNumber'];
+                $arr[] = $result;
             }
             }
         }
         }