summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--idiorm.php5
-rw-r--r--test/bootstrap.php23
2 files changed, 26 insertions, 2 deletions
diff --git a/idiorm.php b/idiorm.php
index 6b021ad..603bcb2 100644
--- a/idiorm.php
+++ b/idiorm.php
@@ -439,6 +439,11 @@
self::$_query_log[$connection_name] = array();
}
+ // Strip out any non-integer indexes from the parameters
+ foreach($parameters as $key => $value) {
+ if (!is_int($key)) unset($parameters[$key]);
+ }
+
if (count($parameters) > 0) {
// Escape the parameters
$parameters = array_map(array(self::get_db($connection_name), 'quote'), $parameters);
diff --git a/test/bootstrap.php b/test/bootstrap.php
index 0e489bd..97f497f 100644
--- a/test/bootstrap.php
+++ b/test/bootstrap.php
@@ -9,9 +9,28 @@ require_once dirname(__FILE__) . '/../idiorm.php';
*/
class MockPDOStatement extends PDOStatement {
private $current_row = 0;
+ private $statement = NULL;
- public function __construct() {}
- public function execute($params) {}
+ /**
+ * Store the statement that gets passed to the constructor
+ */
+ public function __construct($statement) {
+ $this->statement = $statement;
+ }
+
+ /**
+ * Check that the array
+ */
+ public function execute($params) {
+ $count = 0;
+ $m = array();
+ if (preg_match_all('\\?', $this->statement, $m)) {
+ $count = count($m);
+ for ($i = 0; $i < $count; $i++) {
+ if ($params[$i] == NULL) throw new Exception('Incorrect parameter count.');
+ }
+ }
+ }
/**
* Return some dummy data