diff options
-rw-r--r-- | CONTRIBUTING.md | 6 | ||||
-rw-r--r-- | README.markdown | 3 | ||||
-rw-r--r-- | idiorm.php | 12 | ||||
-rw-r--r-- | test/bootstrap.php | 18 |
4 files changed, 36 insertions, 3 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ff1b5f0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,6 @@ +--- +### Feature complete + +Idiorm is now considered to be feature complete as of version 1.4.0. Whilst it will continue to be maintained with bug fixes there will be no further new features added. + +--- diff --git a/README.markdown b/README.markdown index df731ef..4721db7 100644 --- a/README.markdown +++ b/README.markdown @@ -80,11 +80,12 @@ Changelog * `where_id_in()` for selecting multiple records by primary key [[lrlopez](https://github.com/lrlopez)] - [issue #202](https://github.com/j4mie/idiorm/issues/202) * Add compound primary key support [[lrlopez](https://github.com/lrlopez)] - [issue #171](https://github.com/j4mie/idiorm/issues/171) * Add a RAW JOIN source to the query [[moiseevigor](https://github.com/moiseevigor)] - [issue #163](https://github.com/j4mie/idiorm/issues/163) +* Ensure parameters treated by type correctly [[charsleysa](https://github.com/charsleysa)] & [[SneakyBobito](https://github.com/SneakyBobito)] - [issue #206](https://github.com/j4mie/idiorm/issues/206) & [issue #208](https://github.com/j4mie/idiorm/issues/208) * Reduce the type casting on aggregate functions to allow characters [[herroffizier](https://github.com/herroffizier)] - [issue #150](https://github.com/j4mie/idiorm/issues/150) * Prevent invalid method calls from triggering infinite recursion [[michaelward82](https://github.com/michaelward82)] - [issue #152](https://github.com/j4mie/idiorm/issues/152) * Add time to query logging - adds query time parameter to external logger callback function [[AgelxNash](https://github.com/AgelxNash)] - [issue #180](https://github.com/j4mie/idiorm/issues/180) * Changed database array access to ensure it's always properly setup [[falmp](https://github.com/falmp)] - [issue #159](https://github.com/j4mie/idiorm/issues/159) -* Allow unsetting the db (ORM::set_db(null)) to make the test work again [[borrel](https://github.com/borrel)] - [issue #160](https://github.com/j4mie/idiorm/issues/160) +* Allow unsetting the db (`ORM::set_db(null)`) to make the test work again [[borrel](https://github.com/borrel)] - [issue #160](https://github.com/j4mie/idiorm/issues/160) * Correct [issue #176](https://github.com/j4mie/idiorm/issues/176): Ensure database setup before building select [[kendru](https://github.com/kendru)] - [issue #197](https://github.com/j4mie/idiorm/issues/197) * Add HHVM to travis-ci build matrix [[ptarjan](https://github.com/ptarjan)] - [issue #168](https://github.com/j4mie/idiorm/issues/168) * Improve where statement precendence documentation [[thomasahle](https://github.com/thomasahle)] - [issue #190](https://github.com/j4mie/idiorm/issues/190) @@ -410,7 +410,17 @@ $statement = self::get_db($connection_name)->prepare($query); self::$_last_statement = $statement; $time = microtime(true); - $q = $statement->execute($parameters); + + $count = count($parameters); + for ($i = 0; $i < $count; $i++) { + $type = PDO::PARAM_STR; + if (is_null($parameters[$i])) $type = PDO::PARAM_NULL; + if (is_bool($parameters[$i])) $type = PDO::PARAM_BOOL; + if (is_int($parameters[$i])) $type = PDO::PARAM_INT; + $statement->bindParam($i + 1, $parameters[$i], $type); + } + + $q = $statement->execute(); self::_log_query($query, $parameters, $connection_name, (microtime(true)-$time)); return $q; diff --git a/test/bootstrap.php b/test/bootstrap.php index 9a40762..3b3cace 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -10,6 +10,7 @@ require_once dirname(__FILE__) . '/../idiorm.php'; class MockPDOStatement extends PDOStatement { private $current_row = 0; private $statement = NULL; + private $bindParams = array(); /** * Store the statement that gets passed to the constructor @@ -21,9 +22,10 @@ class MockPDOStatement extends PDOStatement { /** * Check that the array */ - public function execute($params) { + public function execute($params = NULL) { $count = 0; $m = array(); + if (is_null($params)) $params = $this->bindParams; if (preg_match_all('/"[^"\\\\]*(?:\\?)[^"\\\\]*"|\'[^\'\\\\]*(?:\\?)[^\'\\\\]*\'|(\\?)/', $this->statement, $m, PREG_SET_ORDER)) { $count = count($m); for ($v = 0; $v < $count; $v++) { @@ -40,6 +42,20 @@ class MockPDOStatement extends PDOStatement { } } } + + /** + * Add data to arrays + */ + public function bindParam($index, $value, $type) + { + // Do check on index, and type + if (!is_int($index)) throw new Exception('Incorrect parameter type. Expected $index to be an integer.'); + if (!is_int($type) || ($type != PDO::PARAM_STR && $type != PDO::PARAM_NULL && $type != PDO::PARAM_BOOL && $type != PDO::PARAM_INT)) + throw new Exception('Incorrect parameter type. Expected $type to be an integer.'); + + // Add param to array + $this->bindParams[$index - 1] = $value; + } /** * Return some dummy data |