Fixed multiple issues in PreparedStatementConditionBuilder
authorMarcel Werk <burntime@woltlab.com>
Tue, 2 Aug 2011 17:52:49 +0000 (19:52 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 2 Aug 2011 17:52:49 +0000 (19:52 +0200)
- added missing exception message
- replaced the usage of isset with array_key_exists

wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php

index 07a898c7664888535643e4f01ce91792c5cce5c3..867ce2ec3749e48a1b57312aab84e38396bfa509 100644 (file)
@@ -28,9 +28,9 @@ class PreparedStatementConditionBuilder extends ConditionBuilder {
        public function add($condition, array $parameters = array()) {
                if (count($parameters)) {
                        $count = 0;
-                       $callback = function ($matches) use (&$count, $parameters) {
-                               if (!isset($parameters[$count])) {
-                                       throw new SystemException();
+                       $callback = function ($matches) use (&$count, $parameters, $condition) {
+                               if (!array_key_exists($count, $parameters)) {
+                                       throw new SystemException("missing parameter for token number " . ($count + 1) . " in condition '".$condition."'");
                                }
 
                                $result = '?';