summaryrefslogtreecommitdiff
path: root/idiorm.php
diff options
context:
space:
mode:
authortag <[email protected]>2012-11-21 18:59:34 -0500
committerSimon Holywell <[email protected]>2012-11-26 13:38:28 +0000
commitf6d786167b9e2a14ebcdb537744b2df1b03ebd00 (patch)
tree105e551afc62aea6154511913f157f3ce4c05735 /idiorm.php
parente2cb2242caf642c6440b6a1d0fc89b3826e85955 (diff)
Add raw_execute() to ORM
Diffstat (limited to 'idiorm.php')
-rw-r--r--idiorm.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/idiorm.php b/idiorm.php
index 2b8917c..85a0632 100644
--- a/idiorm.php
+++ b/idiorm.php
@@ -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.
*