summaryrefslogtreecommitdiffstats
path: root/system/database/DB_active_rec.php
diff options
context:
space:
mode:
authorphilsturgeon <devnull@localhost>2011-06-15 17:00:03 +0200
committerphilsturgeon <devnull@localhost>2011-06-15 17:00:03 +0200
commit0fe54dbaf89a8337d27b9203f74891cf1a799715 (patch)
treece168b3c24788e5a4a31e0cc65b64f54e25ee8a2 /system/database/DB_active_rec.php
parent3a43c7adae7737d68a0eeca663cc2dd3fc5b0cf3 (diff)
parent3ef65bd7491f847fecdab1acc9687f0e90eee09b (diff)
Merged Alex Bilbies MSSQL changes.
Diffstat (limited to 'system/database/DB_active_rec.php')
-rw-r--r--system/database/DB_active_rec.php74
1 files changed, 37 insertions, 37 deletions
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index ee72dbbf4..d94d4a13c 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -59,6 +59,8 @@ class CI_DB_active_record extends CI_DB_driver {
var $ar_cache_orderby = array();
var $ar_cache_set = array();
+ var $ar_no_escape = array();
+ var $ar_cache_no_escape = array();
// --------------------------------------------------------------------
@@ -73,12 +75,6 @@ class CI_DB_active_record extends CI_DB_driver {
*/
function select($select = '*', $escape = NULL)
{
- // Set the global value if this was sepecified
- if (is_bool($escape))
- {
- $this->_protect_identifiers = $escape;
- }
-
if (is_string($select))
{
$select = explode(',', $select);
@@ -91,11 +87,13 @@ class CI_DB_active_record extends CI_DB_driver {
if ($val != '')
{
$this->ar_select[] = $val;
+ $this->ar_no_escape[] = $escape;
if ($this->ar_caching === TRUE)
{
$this->ar_cache_select[] = $val;
$this->ar_cache_exists[] = 'select';
+ $this->ar_cache_no_escape[] = $escape;
}
}
}
@@ -178,7 +176,7 @@ class CI_DB_active_record extends CI_DB_driver {
* select_max()
* select_min()
* select_avg()
- * select_sum()
+ * select_sum()
*
* @access public
* @param string the field
@@ -289,7 +287,7 @@ class CI_DB_active_record extends CI_DB_driver {
{
$val = trim($val);
- // Extract any aliases that might exist. We use this information
+ // Extract any aliases that might exist. We use this information
// in the _protect_identifiers to know whether to add a table prefix
$this->_track_aliases($val);
@@ -335,7 +333,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
}
- // Extract any aliases that might exist. We use this information
+ // Extract any aliases that might exist. We use this information
// in the _protect_identifiers to know whether to add a table prefix
$this->_track_aliases($table);
@@ -444,7 +442,7 @@ class CI_DB_active_record extends CI_DB_driver {
if ( ! $this->_has_operator($k))
{
- $k .= ' =';
+ $k .= ' = ';
}
}
else
@@ -929,7 +927,7 @@ class CI_DB_active_record extends CI_DB_driver {
// --------------------------------------------------------------------
/**
- * The "set" function. Allows key/value pairs to be set for inserting or updating
+ * The "set" function. Allows key/value pairs to be set for inserting or updating
*
* @access public
* @param mixed
@@ -1020,11 +1018,11 @@ class CI_DB_active_record extends CI_DB_driver {
if ($query->num_rows() == 0)
{
- return '0';
+ return 0;
}
$row = $query->row();
- return $row->numrows;
+ return (int) $row->numrows;
}
// --------------------------------------------------------------------
@@ -1087,7 +1085,7 @@ class CI_DB_active_record extends CI_DB_driver {
{
if ($this->db_debug)
{
- //No valid data array. Folds in cases where keys and values did not match up
+ //No valid data array. Folds in cases where keys and values did not match up
return $this->display_error('db_must_use_set');
}
return FALSE;
@@ -1127,7 +1125,7 @@ class CI_DB_active_record extends CI_DB_driver {
// --------------------------------------------------------------------
/**
- * The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts
+ * The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts
*
* @access public
* @param mixed
@@ -1161,7 +1159,7 @@ class CI_DB_active_record extends CI_DB_driver {
if ($escape === FALSE)
{
- $this->ar_set[] = '('.implode(',', $row).')';
+ $this->ar_set[] = '('.implode(',', $row).')';
}
else
{
@@ -1172,7 +1170,7 @@ class CI_DB_active_record extends CI_DB_driver {
$clean[] = $this->escape($value);
}
- $this->ar_set[] = '('.implode(',', $clean).')';
+ $this->ar_set[] = '('.implode(',', $clean).')';
}
}
@@ -1402,7 +1400,7 @@ class CI_DB_active_record extends CI_DB_driver {
// --------------------------------------------------------------------
/**
- * The "set_update_batch" function. Allows key/value pairs to be set for batch updating
+ * The "set_update_batch" function. Allows key/value pairs to be set for batch updating
*
* @access public
* @param array
@@ -1655,7 +1653,7 @@ class CI_DB_active_record extends CI_DB_driver {
return;
}
- // Does the string contain a comma? If so, we need to separate
+ // Does the string contain a comma? If so, we need to separate
// the string into discreet statements
if (strpos($table, ',') !== FALSE)
{
@@ -1685,7 +1683,7 @@ class CI_DB_active_record extends CI_DB_driver {
* Compile the SELECT statement
*
* Generates a query string based on which functions were used.
- * Should not be called directly. The get() function calls it.
+ * Should not be called directly. The get() function calls it.
*
* @access private
* @return string
@@ -1718,7 +1716,7 @@ class CI_DB_active_record extends CI_DB_driver {
// is because until the user calls the from() function we don't know if there are aliases
foreach ($this->ar_select as $key => $val)
{
- $this->ar_select[$key] = $this->_protect_identifiers($val);
+ $this->ar_select[$key] = $this->_protect_identifiers($val, FALSE, $this->ar_no_escape[$key]);
}
$sql .= implode(', ', $this->ar_select);
@@ -1753,9 +1751,7 @@ class CI_DB_active_record extends CI_DB_driver {
if (count($this->ar_where) > 0 OR count($this->ar_like) > 0)
{
- $sql .= "\n";
-
- $sql .= "WHERE ";
+ $sql .= "\nWHERE ";
}
$sql .= implode("\n", $this->ar_where);
@@ -1938,16 +1934,17 @@ class CI_DB_active_record extends CI_DB_driver {
{
$this->_reset_run(
array(
- 'ar_cache_select' => array(),
- 'ar_cache_from' => array(),
- 'ar_cache_join' => array(),
- 'ar_cache_where' => array(),
- 'ar_cache_like' => array(),
- 'ar_cache_groupby' => array(),
- 'ar_cache_having' => array(),
- 'ar_cache_orderby' => array(),
- 'ar_cache_set' => array(),
- 'ar_cache_exists' => array()
+ 'ar_cache_select' => array(),
+ 'ar_cache_from' => array(),
+ 'ar_cache_join' => array(),
+ 'ar_cache_where' => array(),
+ 'ar_cache_like' => array(),
+ 'ar_cache_groupby' => array(),
+ 'ar_cache_having' => array(),
+ 'ar_cache_orderby' => array(),
+ 'ar_cache_set' => array(),
+ 'ar_cache_exists' => array(),
+ 'ar_cache_no_escape' => array()
)
);
}
@@ -1989,12 +1986,14 @@ class CI_DB_active_record extends CI_DB_driver {
{
$this->_track_aliases($this->ar_from);
}
+
+ $this->ar_no_escape = $this->ar_cache_no_escape;
}
// --------------------------------------------------------------------
/**
- * Resets the active record values. Called by the get() function
+ * Resets the active record values. Called by the get() function
*
* @access private
* @param array An array of fields to reset
@@ -2014,7 +2013,7 @@ class CI_DB_active_record extends CI_DB_driver {
// --------------------------------------------------------------------
/**
- * Resets the active record values. Called by the get() function
+ * Resets the active record values. Called by the get() function
*
* @access private
* @return void
@@ -2032,6 +2031,7 @@ class CI_DB_active_record extends CI_DB_driver {
'ar_orderby' => array(),
'ar_wherein' => array(),
'ar_aliased_tables' => array(),
+ 'ar_no_escape' => array(),
'ar_distinct' => FALSE,
'ar_limit' => FALSE,
'ar_offset' => FALSE,