diff options
author | tag <[email protected]> | 2012-11-21 18:59:34 -0500 |
---|---|---|
committer | Simon Holywell <[email protected]> | 2012-11-26 13:38:28 +0000 |
commit | f6d786167b9e2a14ebcdb537744b2df1b03ebd00 (patch) | |
tree | 105e551afc62aea6154511913f157f3ce4c05735 /idiorm.php | |
parent | e2cb2242caf642c6440b6a1d0fc89b3826e85955 (diff) |
Add raw_execute() to ORM
Diffstat (limited to 'idiorm.php')
-rw-r--r-- | idiorm.php | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -256,6 +256,24 @@ } /** + * Executes a raw query as a wrapper for PDOStatement::execute. + * Useful for queries that can't be accomplished through Idiorm, + * particularly those using engine-specific features. + * @example raw_execute('SELECT `name`, AVG(`order`) FROM `customer` GROUP BY `name` HAVING AVG(`order`) > 10') + * @example raw_execute('INSERT OR REPLACE INTO `widget` (`id`, `name`) SELECT `id`, `name` FROM `other_table`') + * @param string $query The raw SQL query + * @param array $parameters Optional bound parameters + * @return bool Success + */ + public static function raw_execute($query, $parameters = array()) { + self::_setup_db(); + + self::_log_query($query, $parameters); + $statement = self::$_db->prepare($query); + return $statement->execute($parameters); + } + + /** * Add a query to the internal query log. Only works if the * 'logging' config option is set to true. * |