From 3c16ca7253de743a6622b485243ee002df57a9bd Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 21 Feb 2014 15:08:00 -0500 Subject: [PATCH] Fix error in < 5.3 in Query Builder --- classes/query_builder.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/classes/query_builder.php b/classes/query_builder.php index 7f98743..31cbe3a 100644 --- a/classes/query_builder.php +++ b/classes/query_builder.php @@ -92,7 +92,7 @@ class Query_Builder implements iQuery_Builder { // List of sql queries executed public $queries; - + // Whether to do only an explain on the query protected $explain = FALSE; @@ -125,9 +125,9 @@ class Query_Builder implements iQuery_Builder { $this->sql = $this->db->sql; $this->util = $this->db->util; } - + // -------------------------------------------------------------------------- - + /** * Destructor */ @@ -281,9 +281,9 @@ class Query_Builder implements iQuery_Builder { $this->select_string = ' DISTINCT '.$this->select_string; return $this; } - + // -------------------------------------------------------------------------- - + /** * Tell the database to give you the query plan instead of result set * @@ -550,10 +550,10 @@ class Query_Builder implements iQuery_Builder { // Simple key value, or an operator $item .= (count($f_array) === 1) ? '=?' : " {$f_array[1]} ?"; - + // Get the type of the first item in the query map $first_item = end($this->query_map); - + // Determine the correct conjunction if (empty($this->query_map)) { @@ -563,7 +563,7 @@ class Query_Builder implements iQuery_Builder { { $conj = ''; } - else + else { $conj = " {$conj} "; } @@ -1062,10 +1062,10 @@ class Query_Builder implements iQuery_Builder { return $this->_run("insert", $table); } - + // -------------------------------------------------------------------------- - - /** + + /** * Create sql for batch insert * * @param string $table @@ -1076,12 +1076,12 @@ class Query_Builder implements iQuery_Builder { { // Get the generated values and sql string list($sql, $data) = $this->db->insert_batch($table, $data); - + if ( ! is_null($sql)) { return $this->_run('', $table, FALSE, $sql, $data); } - + return NULL; } @@ -1261,16 +1261,16 @@ class Query_Builder implements iQuery_Builder { { $sql = $this->_compile($type, $table); } - + if (is_null($vals)) { $vals = array_merge($this->values, (array) $this->where_values); } - + $evals = (is_array($vals)) ? $vals : array(); $start_time = microtime(TRUE); - + if ($simple) { $res = $this->db->query($sql); @@ -1287,12 +1287,12 @@ class Query_Builder implements iQuery_Builder { // Add the interpreted query to the list of executed queries foreach($evals as $k => &$v) { - $v = ( ! is_numeric($v)) ? htmlentities($this->db->quote($v), ENT_HTML401 | ENT_NOQUOTES, 'utf-8', FALSE) : $v; + $v = ( ! is_numeric($v)) ? htmlentities($this->db->quote($v), ENT_NOQUOTES, 'utf-8', FALSE) : $v; } $esql = str_replace('?', "%s", $sql); array_unshift($vals, $esql); array_unshift($evals, $esql); - + $this->queries[] = array( 'time' => $total_time, @@ -1412,7 +1412,7 @@ class Query_Builder implements iQuery_Builder { { $sql = $this->sql->limit($sql, $this->limit, $this->offset); } - + // See what needs to happen to only return the query plan if (isset($this->explain) && $this->explain === TRUE) {