Browse Source

Merge pull request #1454 from TechEmpower/yii2-1405

Fixed validation warnings for single and multi-queries. Part of #1405
Brittany Mazza 10 years ago
parent
commit
e3a30eabdc
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) {
             $arr = $statement->bindValue(':id',mt_rand(1, 10000))->queryOne();
+            $arr['id'] = (int) $arr['id'];
+            $arr['randomNumber'] = (int) $arr['randomNumber'];
         } else {
             if ($queries > 500) $queries = 500;
             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
             while (0 < $queries--) {
                 // 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;
             }
         }