summaryrefslogtreecommitdiffstats
path: root/system/database/drivers
diff options
context:
space:
mode:
authorBarry Mieny <barry@mieny.com>2010-10-04 16:33:58 +0200
committerBarry Mieny <barry@mieny.com>2010-10-04 16:33:58 +0200
commitdd6719738936be31cdaa1758ca86d5eb14dcab3d (patch)
treeb5ef66e31b2d0f4f2c1cbccc367bde92c156e1f9 /system/database/drivers
parent3351fbc56cea19ec3dd603836beb0a420b1ded65 (diff)
Cleanup of stray spaces and tabs
Diffstat (limited to 'system/database/drivers')
-rw-r--r--system/database/drivers/mssql/mssql_driver.php120
-rw-r--r--system/database/drivers/mssql/mssql_forge.php34
-rw-r--r--system/database/drivers/mssql/mssql_result.php24
-rw-r--r--system/database/drivers/mssql/mssql_utility.php2
-rw-r--r--system/database/drivers/mysql/mysql_driver.php144
-rw-r--r--system/database/drivers/mysql/mysql_forge.php30
-rw-r--r--system/database/drivers/mysql/mysql_result.php24
-rw-r--r--system/database/drivers/mysql/mysql_utility.php46
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php120
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php30
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php24
-rw-r--r--system/database/drivers/mysqli/mysqli_utility.php4
-rw-r--r--system/database/drivers/oci8/oci8_driver.php104
-rw-r--r--system/database/drivers/oci8/oci8_forge.php32
-rw-r--r--system/database/drivers/oci8/oci8_result.php30
-rw-r--r--system/database/drivers/odbc/odbc_driver.php108
-rw-r--r--system/database/drivers/odbc/odbc_forge.php38
-rw-r--r--system/database/drivers/odbc/odbc_result.php18
-rw-r--r--system/database/drivers/odbc/odbc_utility.php6
-rw-r--r--system/database/drivers/postgre/postgre_driver.php116
-rw-r--r--system/database/drivers/postgre/postgre_forge.php32
-rw-r--r--system/database/drivers/postgre/postgre_result.php18
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php124
-rw-r--r--system/database/drivers/sqlite/sqlite_forge.php30
-rw-r--r--system/database/drivers/sqlite/sqlite_result.php20
25 files changed, 639 insertions, 639 deletions
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 40900e832..63f9e9cc3 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -31,14 +31,14 @@
class CI_DB_mssql_driver extends CI_DB {
var $dbdriver = 'mssql';
-
+
// The character used for escaping
var $_escape_char = '';
// clause and character used for LIKE escape sequences
var $_like_escape_str = " ESCAPE '%s' ";
var $_like_escape_chr = '!';
-
+
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
@@ -52,7 +52,7 @@ class CI_DB_mssql_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_connect()
{
if ($this->port != '')
@@ -62,7 +62,7 @@ class CI_DB_mssql_driver extends CI_DB {
return @mssql_connect($this->hostname, $this->username, $this->password);
}
-
+
// --------------------------------------------------------------------
/**
@@ -70,7 +70,7 @@ class CI_DB_mssql_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_pconnect()
{
if ($this->port != '')
@@ -80,9 +80,9 @@ class CI_DB_mssql_driver extends CI_DB {
return @mssql_pconnect($this->hostname, $this->username, $this->password);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Reconnect
*
@@ -98,13 +98,13 @@ class CI_DB_mssql_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Select the database
*
* @access private called by the base class
* @return resource
- */
+ */
function db_select()
{
// Note: The brackets are required in the event that the DB name
@@ -113,7 +113,7 @@ class CI_DB_mssql_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Set client character set
*
@@ -129,20 +129,20 @@ class CI_DB_mssql_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
- */
+ */
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @mssql_query($sql, $this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -153,7 +153,7 @@ class CI_DB_mssql_driver extends CI_DB {
* @access private called by execute()
* @param string an SQL query
* @return string
- */
+ */
function _prep_query($sql)
{
return $sql;
@@ -165,15 +165,15 @@ class CI_DB_mssql_driver extends CI_DB {
* Begin Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
-
+
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
@@ -195,8 +195,8 @@ class CI_DB_mssql_driver extends CI_DB {
* Commit Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_commit()
{
if ( ! $this->trans_enabled)
@@ -220,8 +220,8 @@ class CI_DB_mssql_driver extends CI_DB {
* Rollback Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_rollback()
{
if ( ! $this->trans_enabled)
@@ -238,7 +238,7 @@ class CI_DB_mssql_driver extends CI_DB {
$this->simple_query('ROLLBACK TRAN');
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -254,16 +254,16 @@ class CI_DB_mssql_driver extends CI_DB {
if (is_array($str))
{
foreach($str as $key => $val)
- {
+ {
$str[$key] = $this->escape_str($val, $like);
- }
-
- return $str;
- }
-
+ }
+
+ return $str;
+ }
+
// Escape single quotes
$str = str_replace("'", "''", remove_invisible_characters($str));
-
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
@@ -271,10 +271,10 @@ class CI_DB_mssql_driver extends CI_DB {
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
/**
@@ -287,7 +287,7 @@ class CI_DB_mssql_driver extends CI_DB {
{
return @mssql_rows_affected($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -312,7 +312,7 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Parse major version
*
- * Grabs the major version number from the
+ * Grabs the major version number from the
* database server version string passed in.
*
* @access private
@@ -382,14 +382,14 @@ class CI_DB_mssql_driver extends CI_DB {
function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
-
+
// for future compatibility
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
return FALSE; // not currently supported
}
-
+
return $sql;
}
@@ -406,7 +406,7 @@ class CI_DB_mssql_driver extends CI_DB {
*/
function _list_columns($table = '')
{
- return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
+ return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
}
// --------------------------------------------------------------------
@@ -422,7 +422,7 @@ class CI_DB_mssql_driver extends CI_DB {
*/
function _field_data($table)
{
- return "SELECT TOP 1 * FROM ".$table;
+ return "SELECT TOP 1 * FROM ".$table;
}
// --------------------------------------------------------------------
@@ -437,7 +437,7 @@ class CI_DB_mssql_driver extends CI_DB {
{
return mssql_get_last_message();
}
-
+
// --------------------------------------------------------------------
/**
@@ -474,26 +474,26 @@ class CI_DB_mssql_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
-
+ $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
- }
+ }
}
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
+ $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
-
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
-
+
// --------------------------------------------------------------------
/**
@@ -512,12 +512,12 @@ class CI_DB_mssql_driver extends CI_DB {
{
$tables = array($tables);
}
-
+
return implode(', ', $tables);
}
// --------------------------------------------------------------------
-
+
/**
* Insert statement
*
@@ -530,10 +530,10 @@ class CI_DB_mssql_driver extends CI_DB {
* @return string
*/
function _insert($table, $keys, $values)
- {
+ {
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
-
+
// --------------------------------------------------------------------
/**
@@ -555,21 +555,21 @@ class CI_DB_mssql_driver extends CI_DB {
{
$valstr[] = $key." = ".$val;
}
-
+
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
+
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
-
+
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -582,12 +582,12 @@ class CI_DB_mssql_driver extends CI_DB {
* @access public
* @param string the table name
* @return string
- */
+ */
function _truncate($table)
{
return "TRUNCATE ".$table;
}
-
+
// --------------------------------------------------------------------
/**
@@ -600,7 +600,7 @@ class CI_DB_mssql_driver extends CI_DB {
* @param array the where clause
* @param string the limit clause
* @return string
- */
+ */
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -618,7 +618,7 @@ class CI_DB_mssql_driver extends CI_DB {
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
return "DELETE FROM ".$table.$conditions.$limit;
}
@@ -638,8 +638,8 @@ class CI_DB_mssql_driver extends CI_DB {
function _limit($sql, $limit, $offset)
{
$i = $limit + $offset;
-
- return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
+
+ return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
}
// --------------------------------------------------------------------
@@ -654,7 +654,7 @@ class CI_DB_mssql_driver extends CI_DB {
function _close($conn_id)
{
@mssql_close($conn_id);
- }
+ }
}
diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php
index f6a17811f..5aa4406b1 100644
--- a/system/database/drivers/mssql/mssql_forge.php
+++ b/system/database/drivers/mssql/mssql_forge.php
@@ -79,12 +79,12 @@ class CI_DB_mssql_forge extends CI_DB_forge {
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
-
+
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
-
+
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
@@ -100,41 +100,41 @@ class CI_DB_mssql_forge extends CI_DB_forge {
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
-
+
$sql .= "\n\t".$this->db->_protect_identifiers($field);
-
+
$sql .= ' '.$attributes['TYPE'];
-
+
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
-
+
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
-
+
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
-
+
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
- $sql .= ' NOT NULL';
+ $sql .= ' NOT NULL';
}
-
+
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
-
+
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
@@ -147,24 +147,24 @@ class CI_DB_mssql_forge extends CI_DB_forge {
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
-
+
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
-
+
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
}
}
-
+
$sql .= "\n)";
return $sql;
@@ -218,9 +218,9 @@ class CI_DB_mssql_forge extends CI_DB_forge {
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
-
+
return $sql;
-
+
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php
index e7b338045..09b1ec80b 100644
--- a/system/database/drivers/mssql/mssql_result.php
+++ b/system/database/drivers/mssql/mssql_result.php
@@ -25,7 +25,7 @@
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mssql_result extends CI_DB_result {
-
+
/**
* Number of rows in the result set
*
@@ -36,7 +36,7 @@ class CI_DB_mssql_result extends CI_DB_result {
{
return @mssql_num_rows($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -67,7 +67,7 @@ class CI_DB_mssql_result extends CI_DB_result {
{
$field_names[] = $field->name;
}
-
+
return $field_names;
}
@@ -85,17 +85,17 @@ class CI_DB_mssql_result extends CI_DB_result {
{
$retval = array();
while ($field = mssql_fetch_field($this->result_id))
- {
- $F = new stdClass();
- $F->name = $field->name;
- $F->type = $field->type;
+ {
+ $F = new stdClass();
+ $F->name = $field->name;
+ $F->type = $field->type;
$F->max_length = $field->max_length;
$F->primary_key = 0;
$F->default = '';
-
+
$retval[] = $F;
}
-
+
return $retval;
}
@@ -105,7 +105,7 @@ class CI_DB_mssql_result extends CI_DB_result {
* Free the result
*
* @return null
- */
+ */
function free_result()
{
if (is_resource($this->result_id))
@@ -131,7 +131,7 @@ class CI_DB_mssql_result extends CI_DB_result {
{
return mssql_data_seek($this->result_id, $n);
}
-
+
// --------------------------------------------------------------------
/**
@@ -146,7 +146,7 @@ class CI_DB_mssql_result extends CI_DB_result {
{
return mssql_fetch_assoc($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
index 751be146c..e58c7e0c3 100644
--- a/system/database/drivers/mssql/mssql_utility.php
+++ b/system/database/drivers/mssql/mssql_utility.php
@@ -52,7 +52,7 @@ class CI_DB_mssql_utility extends CI_DB_utility {
}
// --------------------------------------------------------------------
-
+
/**
* Repair table query
*
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index d684c8a49..cb985a764 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -43,9 +43,9 @@ class CI_DB_mysql_driver extends CI_DB {
* Whether to use the MySQL "delete hack" which allows the number
* of affected rows to be shown. Uses a preg_replace when enabled,
* adding a bit more processing to all queries.
- */
+ */
var $delete_hack = TRUE;
-
+
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
@@ -59,17 +59,17 @@ class CI_DB_mysql_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_connect()
{
if ($this->port != '')
{
$this->hostname .= ':'.$this->port;
}
-
+
return @mysql_connect($this->hostname, $this->username, $this->password, TRUE);
}
-
+
// --------------------------------------------------------------------
/**
@@ -77,7 +77,7 @@ class CI_DB_mysql_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_pconnect()
{
if ($this->port != '')
@@ -87,7 +87,7 @@ class CI_DB_mysql_driver extends CI_DB {
return @mysql_pconnect($this->hostname, $this->username, $this->password);
}
-
+
// --------------------------------------------------------------------
/**
@@ -108,13 +108,13 @@ class CI_DB_mysql_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Select the database
*
* @access private called by the base class
* @return resource
- */
+ */
function db_select()
{
return @mysql_select_db($this->database, $this->conn_id);
@@ -136,7 +136,7 @@ class CI_DB_mysql_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Version number query string
*
@@ -156,13 +156,13 @@ class CI_DB_mysql_driver extends CI_DB {
* @access private called by the base class
* @param string an SQL query
* @return resource
- */
+ */
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @mysql_query($sql, $this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -173,7 +173,7 @@ class CI_DB_mysql_driver extends CI_DB {
* @access private called by execute()
* @param string an SQL query
* @return string
- */
+ */
function _prep_query($sql)
{
// "DELETE FROM TABLE" returns 0 affected rows This hack modifies
@@ -185,7 +185,7 @@ class CI_DB_mysql_driver extends CI_DB {
$sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql);
}
}
-
+
return $sql;
}
@@ -195,15 +195,15 @@ class CI_DB_mysql_driver extends CI_DB {
* Begin Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
-
+
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
@@ -214,7 +214,7 @@ class CI_DB_mysql_driver extends CI_DB {
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
-
+
$this->simple_query('SET AUTOCOMMIT=0');
$this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
return TRUE;
@@ -226,8 +226,8 @@ class CI_DB_mysql_driver extends CI_DB {
* Commit Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_commit()
{
if ( ! $this->trans_enabled)
@@ -252,8 +252,8 @@ class CI_DB_mysql_driver extends CI_DB {
* Rollback Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_rollback()
{
if ( ! $this->trans_enabled)
@@ -271,7 +271,7 @@ class CI_DB_mysql_driver extends CI_DB {
$this->simple_query('SET AUTOCOMMIT=1');
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -282,17 +282,17 @@ class CI_DB_mysql_driver extends CI_DB {
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
- {
+ function escape_str($str, $like = FALSE)
+ {
if (is_array($str))
{
foreach($str as $key => $val)
- {
+ {
$str[$key] = $this->escape_str($val, $like);
- }
-
- return $str;
- }
+ }
+
+ return $str;
+ }
if (function_exists('mysql_real_escape_string') AND is_resource($this->conn_id))
{
@@ -306,16 +306,16 @@ class CI_DB_mysql_driver extends CI_DB {
{
$str = addslashes($str);
}
-
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
/**
@@ -328,7 +328,7 @@ class CI_DB_mysql_driver extends CI_DB {
{
return @mysql_affected_rows($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -360,7 +360,7 @@ class CI_DB_mysql_driver extends CI_DB {
{
return 0;
}
-
+
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
@@ -385,7 +385,7 @@ class CI_DB_mysql_driver extends CI_DB {
*/
function _list_tables($prefix_limit = FALSE)
{
- $sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char;
+ $sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char;
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
@@ -394,7 +394,7 @@ class CI_DB_mysql_driver extends CI_DB {
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -439,7 +439,7 @@ class CI_DB_mysql_driver extends CI_DB {
{
return mysql_error($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -475,26 +475,26 @@ class CI_DB_mysql_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
-
+ $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
- }
+ }
}
-
+
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
+ $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
-
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
-
+
// --------------------------------------------------------------------
/**
@@ -513,12 +513,12 @@ class CI_DB_mysql_driver extends CI_DB {
{
$tables = array($tables);
}
-
+
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
-
+
/**
* Insert statement
*
@@ -531,13 +531,13 @@ class CI_DB_mysql_driver extends CI_DB {
* @return string
*/
function _insert($table, $keys, $values)
- {
+ {
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Replace statement
*
@@ -550,10 +550,10 @@ class CI_DB_mysql_driver extends CI_DB {
* @return string
*/
function _replace($table, $keys, $values)
- {
+ {
return "REPLACE INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
-
+
// --------------------------------------------------------------------
/**
@@ -568,10 +568,10 @@ class CI_DB_mysql_driver extends CI_DB {
* @return string
*/
function _insert_batch($table, $keys, $values)
- {
+ {
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
}
-
+
// --------------------------------------------------------------------
@@ -594,17 +594,17 @@ class CI_DB_mysql_driver extends CI_DB {
{
$valstr[] = $key." = ".$val;
}
-
+
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
+
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
-
+
return $sql;
}
@@ -630,16 +630,16 @@ class CI_DB_mysql_driver extends CI_DB {
foreach($values as $key => $val)
{
$ids[] = $val[$index];
-
+
foreach(array_keys($val) as $field)
- {
+ {
if ($field != $index)
{
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
}
}
}
-
+
$sql = "UPDATE ".$table." SET ";
$cases = '';
@@ -650,14 +650,14 @@ class CI_DB_mysql_driver extends CI_DB {
{
$cases .= $row."\n";
}
-
+
$cases .= 'ELSE '.$k.' END, ';
}
-
+
$sql .= substr($cases, 0, -2);
-
+
$sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
-
+
return $sql;
}
@@ -674,12 +674,12 @@ class CI_DB_mysql_driver extends CI_DB {
* @access public
* @param string the table name
* @return string
- */
+ */
function _truncate($table)
{
return "TRUNCATE ".$table;
}
-
+
// --------------------------------------------------------------------
/**
@@ -692,7 +692,7 @@ class CI_DB_mysql_driver extends CI_DB {
* @param array the where clause
* @param string the limit clause
* @return string
- */
+ */
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -710,7 +710,7 @@ class CI_DB_mysql_driver extends CI_DB {
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
return "DELETE FROM ".$table.$conditions.$limit;
}
@@ -728,7 +728,7 @@ class CI_DB_mysql_driver extends CI_DB {
* @return string
*/
function _limit($sql, $limit, $offset)
- {
+ {
if ($offset == 0)
{
$offset = '';
@@ -737,7 +737,7 @@ class CI_DB_mysql_driver extends CI_DB {
{
$offset .= ", ";
}
-
+
return $sql."LIMIT ".$offset.$limit;
}
@@ -754,7 +754,7 @@ class CI_DB_mysql_driver extends CI_DB {
{
@mysql_close($conn_id);
}
-
+
}
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index ccacf99f8..973f32dcb 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -23,7 +23,7 @@
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysql_forge extends CI_DB_forge {
-
+
/**
* Create database
*
@@ -76,52 +76,52 @@ class CI_DB_mysql_forge extends CI_DB_forge {
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
-
+
$sql .= "\n\t".$this->db->_protect_identifiers($field);
if (array_key_exists('NAME', $attributes))
{
$sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
}
-
+
if (array_key_exists('TYPE', $attributes))
{
$sql .= ' '.$attributes['TYPE'];
}
-
+
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
-
+
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
-
+
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
-
+
if (array_key_exists('NULL', $attributes))
{
$sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL';
}
-
+
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
-
+
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
-
+
return $sql;
}
@@ -141,12 +141,12 @@ class CI_DB_mysql_forge extends CI_DB_forge {
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
-
+
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
-
+
$sql .= $this->db->_escape_identifiers($table)." (";
$sql .= $this->_process_fields($fields);
@@ -165,14 +165,14 @@ class CI_DB_mysql_forge extends CI_DB_forge {
if (is_array($key))
{
$key_name = $this->db->_protect_identifiers(implode('_', $key));
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->_protect_identifiers($key);
}
else
{
$key_name = $this->db->_protect_identifiers($key);
$key = array($key_name);
}
-
+
$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";
}
}
@@ -226,7 +226,7 @@ class CI_DB_mysql_forge extends CI_DB_forge {
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
-
+
return $sql;
}
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index acc586626..0140ec647 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -36,7 +36,7 @@ class CI_DB_mysql_result extends CI_DB_result {
{
return @mysql_num_rows($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -49,7 +49,7 @@ class CI_DB_mysql_result extends CI_DB_result {
{
return @mysql_num_fields($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -67,7 +67,7 @@ class CI_DB_mysql_result extends CI_DB_result {
{
$field_names[] = $field->name;
}
-
+
return $field_names;
}
@@ -85,27 +85,27 @@ class CI_DB_mysql_result extends CI_DB_result {
{
$retval = array();
while ($field = mysql_fetch_field($this->result_id))
- {
+ {
$F = new stdClass();
- $F->name = $field->name;
- $F->type = $field->type;
+ $F->name = $field->name;
+ $F->type = $field->type;
$F->default = $field->def;
$F->max_length = $field->max_length;
$F->primary_key = $field->primary_key;
-
+
$retval[] = $F;
}
-
+
return $retval;
}
-
+
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
- */
+ */
function free_result()
{
if (is_resource($this->result_id))
@@ -146,7 +146,7 @@ class CI_DB_mysql_result extends CI_DB_result {
{
return mysql_fetch_assoc($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -161,7 +161,7 @@ class CI_DB_mysql_result extends CI_DB_result {
{
return mysql_fetch_object($this->result_id);
}
-
+
}
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index c4a970cfd..3b574c6f4 100644
--- a/system/database/drivers/mysql/mysql_utility.php
+++ b/system/database/drivers/mysql/mysql_utility.php
@@ -84,7 +84,7 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// Extract the prefs for simplicity
extract($params);
-
+
// Build the output
$output = '';
foreach ((array)$tables as $table)
@@ -97,31 +97,31 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// Get the table schema
$query = $this->db->query("SHOW CREATE TABLE `".$this->db->database.'`.'.$table);
-
+
// No result means the table name was invalid
if ($query === FALSE)
{
continue;
}
-
+
// Write out the table schema
$output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline;
- if ($add_drop == TRUE)
- {
+ if ($add_drop == TRUE)
+ {
$output .= 'DROP TABLE IF EXISTS '.$table.';'.$newline.$newline;
}
-
+
$i = 0;
$result = $query->result_array();
foreach ($result[0] as $val)
{
if ($i++ % 2)
- {
+ {
$output .= $val.';'.$newline.$newline;
}
}
-
+
// If inserts are not needed we're done...
if ($add_insert == FALSE)
{
@@ -130,16 +130,16 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// Grab all the data from the current table
$query = $this->db->query("SELECT * FROM $table");
-
+
if ($query->num_rows() == 0)
{
continue;
}
-
+
// Fetch the field names and determine if the field is an
// integer type. We use this info to decide whether to
// surround the data with quotes or not
-
+
$i = 0;
$field_str = '';
$is_int = array();
@@ -148,24 +148,24 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// Most versions of MySQL store timestamp as a string
$is_int[$i] = (in_array(
strtolower(mysql_field_type($query->result_id, $i)),
- array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'),
+ array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'),
TRUE)
) ? TRUE : FALSE;
-
+
// Create a string of field names
$field_str .= '`'.$field->name.'`, ';
$i++;
}
-
+
// Trim off the end comma
$field_str = preg_replace( "/, $/" , "" , $field_str);
-
-
+
+
// Build the insert string
foreach ($query->result_array() as $row)
{
$val_str = '';
-
+
$i = 0;
foreach ($row as $v)
{
@@ -184,21 +184,21 @@ class CI_DB_mysql_utility extends CI_DB_utility {
else
{
$val_str .= $v;
- }
- }
-
+ }
+ }
+
// Append a comma
$val_str .= ', ';
$i++;
}
-
+
// Remove the comma at the end of the string
$val_str = preg_replace( "/, $/" , "" , $val_str);
-
+
// Build the INSERT string
$output .= 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline;
}
-
+
$output .= $newline.$newline;
}
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index d0e2defec..69e092839 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -31,7 +31,7 @@
class CI_DB_mysqli_driver extends CI_DB {
var $dbdriver = 'mysqli';
-
+
// The character used for escaping
var $_escape_char = '`';
@@ -51,7 +51,7 @@ class CI_DB_mysqli_driver extends CI_DB {
* Whether to use the MySQL "delete hack" which allows the number
* of affected rows to be shown. Uses a preg_replace when enabled,
* adding a bit more processing to all queries.
- */
+ */
var $delete_hack = TRUE;
// --------------------------------------------------------------------
@@ -61,12 +61,12 @@ class CI_DB_mysqli_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_connect()
{
if ($this->port != '')
{
- return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port);
+ return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port);
}
else
{
@@ -82,12 +82,12 @@ class CI_DB_mysqli_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_pconnect()
{
return $this->db_connect();
}
-
+
// --------------------------------------------------------------------
/**
@@ -114,7 +114,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_select()
{
return @mysqli_select_db($this->conn_id, $this->database);
@@ -136,7 +136,7 @@ class CI_DB_mysqli_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Version number query string
*
@@ -156,14 +156,14 @@ class CI_DB_mysqli_driver extends CI_DB {
* @access private called by the base class
* @param string an SQL query
* @return resource
- */
+ */
function _execute($sql)
{
- $sql = $this->_prep_query($sql);
+ $sql = $this->_prep_query($sql);
$result = @mysqli_query($this->conn_id, $sql);
return $result;
}
-
+
// --------------------------------------------------------------------
/**
@@ -174,7 +174,7 @@ class CI_DB_mysqli_driver extends CI_DB {
* @access private called by execute()
* @param string an SQL query
* @return string
- */
+ */
function _prep_query($sql)
{
// "DELETE FROM TABLE" returns 0 affected rows This hack modifies
@@ -186,7 +186,7 @@ class CI_DB_mysqli_driver extends CI_DB {
$sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql);
}
}
-
+
return $sql;
}
@@ -196,15 +196,15 @@ class CI_DB_mysqli_driver extends CI_DB {
* Begin Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
-
+
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
@@ -227,8 +227,8 @@ class CI_DB_mysqli_driver extends CI_DB {
* Commit Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_commit()
{
if ( ! $this->trans_enabled)
@@ -253,8 +253,8 @@ class CI_DB_mysqli_driver extends CI_DB {
* Rollback Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_rollback()
{
if ( ! $this->trans_enabled)
@@ -283,17 +283,17 @@ class CI_DB_mysqli_driver extends CI_DB {
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach($str as $key => $val)
- {
+ {
$str[$key] = $this->escape_str($val, $like);
- }
-
- return $str;
- }
+ }
+
+ return $str;
+ }
if (function_exists('mysqli_real_escape_string') AND is_object($this->conn_id))
{
@@ -307,16 +307,16 @@ class CI_DB_mysqli_driver extends CI_DB {
{
$str = addslashes($str);
}
-
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
/**
@@ -329,7 +329,7 @@ class CI_DB_mysqli_driver extends CI_DB {
{
return @mysqli_affected_rows($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -386,13 +386,13 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
function _list_tables($prefix_limit = FALSE)
{
- $sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char;
-
+ $sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char;
+
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%'";
}
-
+
return $sql;
}
@@ -440,7 +440,7 @@ class CI_DB_mysqli_driver extends CI_DB {
{
return mysqli_error($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -471,31 +471,31 @@ class CI_DB_mysqli_driver extends CI_DB {
{
return $item;
}
-
+
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
-
+ $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
- }
+ }
}
-
+
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
+ $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
-
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
-
+
// --------------------------------------------------------------------
/**
@@ -514,12 +514,12 @@ class CI_DB_mysqli_driver extends CI_DB {
{
$tables = array($tables);
}
-
+
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
-
+
/**
* Insert statement
*
@@ -532,10 +532,10 @@ class CI_DB_mysqli_driver extends CI_DB {
* @return string
*/
function _insert($table, $keys, $values)
- {
+ {
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
-
+
// --------------------------------------------------------------------
/**
@@ -557,21 +557,21 @@ class CI_DB_mysqli_driver extends CI_DB {
{
$valstr[] = $key." = ".$val;
}
-
+
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
+
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
-
+
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
-
+
$sql .= $orderby.$limit;
-
+
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -584,12 +584,12 @@ class CI_DB_mysqli_driver extends CI_DB {
* @access public
* @param string the table name
* @return string
- */
+ */
function _truncate($table)
{
return "TRUNCATE ".$table;
}
-
+
// --------------------------------------------------------------------
/**
@@ -602,7 +602,7 @@ class CI_DB_mysqli_driver extends CI_DB {
* @param array the where clause
* @param string the limit clause
* @return string
- */
+ */
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -620,7 +620,7 @@ class CI_DB_mysqli_driver extends CI_DB {
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
return "DELETE FROM ".$table.$conditions.$limit;
}
@@ -638,14 +638,14 @@ class CI_DB_mysqli_driver extends CI_DB {
* @return string
*/
function _limit($sql, $limit, $offset)
- {
+ {
$sql .= "LIMIT ".$limit;
-
+
if ($offset > 0)
{
$sql .= " OFFSET ".$offset;
}
-
+
return $sql;
}
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index 262d491ed..85491a873 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -23,7 +23,7 @@
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysqli_forge extends CI_DB_forge {
-
+
/**
* Create database
*
@@ -76,52 +76,52 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
-
+
$sql .= "\n\t".$this->db->_protect_identifiers($field);
if (array_key_exists('NAME', $attributes))
{
$sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
}
-
+
if (array_key_exists('TYPE', $attributes))
{
$sql .= ' '.$attributes['TYPE'];
}
-
+
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
-
+
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
-
+
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
-
+
if (array_key_exists('NULL', $attributes))
{
$sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL';
}
-
+
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
-
+
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
-
+
return $sql;
}
@@ -141,12 +141,12 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
-
+
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
-
+
$sql .= $this->db->_escape_identifiers($table)." (";
$sql .= $this->_process_fields($fields);
@@ -165,14 +165,14 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
if (is_array($key))
{
$key_name = $this->db->_protect_identifiers(implode('_', $key));
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->_protect_identifiers($key);
}
else
{
$key_name = $this->db->_protect_identifiers($key);
$key = array($key_name);
}
-
+
$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";
}
}
@@ -226,7 +226,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
-
+
return $sql;
}
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index 81d22cc9c..dd58ed878 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -25,7 +25,7 @@
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysqli_result extends CI_DB_result {
-
+
/**
* Number of rows in the result set
*
@@ -36,7 +36,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
{
return @mysqli_num_rows($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -67,7 +67,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
{
$field_names[] = $field->name;
}
-
+
return $field_names;
}
@@ -85,17 +85,17 @@ class CI_DB_mysqli_result extends CI_DB_result {
{
$retval = array();
while ($field = mysqli_fetch_field($this->result_id))
- {
- $F = new stdClass();
- $F->name = $field->name;
- $F->type = $field->type;
+ {
+ $F = new stdClass();
+ $F->name = $field->name;
+ $F->type = $field->type;
$F->default = $field->def;
$F->max_length = $field->max_length;
$F->primary_key = ($field->flags & MYSQLI_PRI_KEY_FLAG) ? 1 : 0;
-
+
$retval[] = $F;
}
-
+
return $retval;
}
@@ -105,7 +105,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
* Free the result
*
* @return null
- */
+ */
function free_result()
{
if (is_object($this->result_id))
@@ -146,7 +146,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
{
return mysqli_fetch_assoc($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -161,7 +161,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
{
return mysqli_fetch_object($this->result_id);
}
-
+
}
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index 3ba14d25a..e0dbca7c0 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -23,7 +23,7 @@
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysqli_utility extends CI_DB_utility {
-
+
/**
* List databases
*
@@ -34,7 +34,7 @@ class CI_DB_mysqli_utility extends CI_DB_utility {
{
return "SHOW DATABASES";
}
-
+
// --------------------------------------------------------------------
/**
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 6f317d2e6..fb65ad8a1 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -4,12 +4,12 @@
*
* An open source application development framework for PHP 4.3.2 or newer
*
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
+ * @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
- * @since Version 1.0
+ * @since Version 1.0
* @filesource
*/
@@ -22,10 +22,10 @@
* creates dynamically based on whether the active record
* class is being used or not.
*
- * @package CodeIgniter
+ * @package CodeIgniter
* @subpackage Drivers
* @category Database
- * @author ExpressionEngine Dev Team
+ * @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
@@ -44,14 +44,14 @@
class CI_DB_oci8_driver extends CI_DB {
var $dbdriver = 'oci8';
-
+
// The character used for excaping
var $_escape_char = '"';
-
+
// clause and character used for LIKE escape sequences
var $_like_escape_str = " escape '%s' ";
var $_like_escape_chr = '!';
-
+
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
@@ -141,7 +141,7 @@ class CI_DB_oci8_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Version number query string
*
@@ -248,7 +248,7 @@ class CI_DB_oci8_driver extends CI_DB {
}
return FALSE;
}
-
+
// build the query string
$sql = "begin $package.$procedure(";
@@ -256,20 +256,20 @@ class CI_DB_oci8_driver extends CI_DB {
foreach($params as $param)
{
$sql .= $param['name'] . ",";
-
+
if (array_key_exists('type', $param) && ($param['type'] == OCI_B_CURSOR))
{
$have_cursor = TRUE;
}
}
$sql = trim($sql, ",") . "); end;";
-
+
$this->stmt_id = FALSE;
$this->_set_stmt_id($sql);
$this->_bind_params($params);
$this->query($sql, FALSE, $have_cursor);
}
-
+
// --------------------------------------------------------------------
/**
@@ -284,10 +284,10 @@ class CI_DB_oci8_driver extends CI_DB {
{
return;
}
-
+
foreach ($params as $param)
{
- foreach (array('name', 'value', 'type', 'length') as $val)
+ foreach (array('name', 'value', 'type', 'length') as $val)
{
if ( ! isset($param[$val]))
{
@@ -305,26 +305,26 @@ class CI_DB_oci8_driver extends CI_DB {
* Begin Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
-
+
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
-
+
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
-
+
$this->_commit = OCI_DEFAULT;
return TRUE;
}
@@ -335,8 +335,8 @@ class CI_DB_oci8_driver extends CI_DB {
* Commit Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_commit()
{
if ( ! $this->trans_enabled)
@@ -361,8 +361,8 @@ class CI_DB_oci8_driver extends CI_DB {
* Rollback Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_rollback()
{
if ( ! $this->trans_enabled)
@@ -396,15 +396,15 @@ class CI_DB_oci8_driver extends CI_DB {
if (is_array($str))
{
foreach($str as $key => $val)
- {
+ {
$str[$key] = $this->escape_str($val, $like);
- }
-
- return $str;
- }
+ }
+
+ return $str;
+ }
$str = remove_invisible_characters($str);
-
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
@@ -412,7 +412,7 @@ class CI_DB_oci8_driver extends CI_DB {
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
-
+
return $str;
}
@@ -492,7 +492,7 @@ class CI_DB_oci8_driver extends CI_DB {
{
$sql .= " WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
-
+
return $sql;
}
@@ -555,7 +555,7 @@ class CI_DB_oci8_driver extends CI_DB {
$error = ocierror($this->conn_id);
return $error['code'];
}
-
+
// --------------------------------------------------------------------
/**
@@ -578,26 +578,26 @@ class CI_DB_oci8_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
-
+ $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
- }
+ }
}
-
+
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
+ $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
-
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
-
+
// --------------------------------------------------------------------
/**
@@ -616,12 +616,12 @@ class CI_DB_oci8_driver extends CI_DB {
{
$tables = array($tables);
}
-
+
return implode(', ', $tables);
}
// --------------------------------------------------------------------
-
+
/**
* Insert statement
*
@@ -659,17 +659,17 @@ class CI_DB_oci8_driver extends CI_DB {
{
$valstr[] = $key." = ".$val;
}
-
+
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
+
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
-
+
return $sql;
}
@@ -685,12 +685,12 @@ class CI_DB_oci8_driver extends CI_DB {
* @access public
* @param string the table name
* @return string
- */
+ */
function _truncate($table)
{
return "TRUNCATE TABLE ".$table;
}
-
+
// --------------------------------------------------------------------
/**
@@ -703,7 +703,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param array the where clause
* @param string the limit clause
* @return string
- */
+ */
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -721,7 +721,7 @@ class CI_DB_oci8_driver extends CI_DB {
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
return "DELETE FROM ".$table.$conditions.$limit;
}
@@ -752,7 +752,7 @@ class CI_DB_oci8_driver extends CI_DB {
$this->limit_used = TRUE;
return $newsql;
- }
+ }
// --------------------------------------------------------------------
diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php
index d77ed8de6..1d369ae32 100644
--- a/system/database/drivers/oci8/oci8_forge.php
+++ b/system/database/drivers/oci8/oci8_forge.php
@@ -66,12 +66,12 @@ class CI_DB_oci8_forge extends CI_DB_forge {
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
-
+
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
-
+
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
@@ -87,41 +87,41 @@ class CI_DB_oci8_forge extends CI_DB_forge {
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
-
+
$sql .= "\n\t".$this->db->_protect_identifiers($field);
-
+
$sql .= ' '.$attributes['TYPE'];
-
+
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
-
+
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
-
+
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
-
+
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
- $sql .= ' NOT NULL';
+ $sql .= ' NOT NULL';
}
-
+
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
-
+
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
@@ -141,17 +141,17 @@ class CI_DB_oci8_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
-
+
$sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")";
}
}
-
+
$sql .= "\n)";
return $sql;
@@ -218,9 +218,9 @@ class CI_DB_oci8_forge extends CI_DB_forge {
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
-
+
return $sql;
-
+
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
index cab538e21..647ec6e43 100644
--- a/system/database/drivers/oci8/oci8_result.php
+++ b/system/database/drivers/oci8/oci8_result.php
@@ -4,12 +4,12 @@
*
* An open source application development framework for PHP 4.3.2 or newer
*
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
+ * @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
- * @since Version 1.0
+ * @since Version 1.0
* @filesource
*/
@@ -21,7 +21,7 @@
* This class extends the parent result class: CI_DB_result
*
* @category Database
- * @author ExpressionEngine Dev Team
+ * @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_oci8_result extends CI_DB_result {
@@ -35,7 +35,7 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Oracle doesn't have a graceful way to retun the number of rows
* so we have to use what amounts to a hack.
- *
+ *
*
* @access public
* @return integer
@@ -111,7 +111,7 @@ class CI_DB_oci8_result extends CI_DB_result {
$fieldCount = $this->num_fields();
for ($c = 1; $c <= $fieldCount; $c++)
{
- $F = new stdClass();
+ $F = new stdClass();
$F->name = ocicolumnname($this->stmt_id, $c);
$F->type = ocicolumntype($this->stmt_id, $c);
$F->max_length = ocicolumnsize($this->stmt_id, $c);
@@ -128,12 +128,12 @@ class CI_DB_oci8_result extends CI_DB_result {
* Free the result
*
* @return null
- */
+ */
function free_result()
{
if (is_resource($this->result_id))
{
- ocifreestatement($this->result_id);
+ ocifreestatement($this->result_id);
$this->result_id = FALSE;
}
}
@@ -151,8 +151,8 @@ class CI_DB_oci8_result extends CI_DB_result {
function _fetch_assoc(&$row)
{
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
-
- return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
+
+ return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
}
// --------------------------------------------------------------------
@@ -166,17 +166,17 @@ class CI_DB_oci8_result extends CI_DB_result {
* @return object
*/
function _fetch_object()
- {
+ {
$result = array();
// If PHP 5 is being used we can fetch an result object
if (function_exists('oci_fetch_object'))
{
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
-
+
return @oci_fetch_object($id);
}
-
+
// If PHP 4 is being used we have to build our own result
foreach ($this->result_array() as $key => $val)
{
@@ -192,7 +192,7 @@ class CI_DB_oci8_result extends CI_DB_result {
{
$obj->$key = $val;
}
-
+
$result[] = $obj;
}
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 6e682313f..0e2c7de5f 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -31,14 +31,14 @@
class CI_DB_odbc_driver extends CI_DB {
var $dbdriver = 'odbc';
-
+
// the character used to excape - not necessary for ODBC
var $_escape_char = '';
-
+
// clause and character used for LIKE escape sequences
var $_like_escape_str = " {escape '%s'} ";
var $_like_escape_chr = '!';
-
+
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
@@ -51,7 +51,7 @@ class CI_DB_odbc_driver extends CI_DB {
function CI_DB_odbc_driver($params)
{
parent::CI_DB($params);
-
+
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
}
@@ -60,12 +60,12 @@ class CI_DB_odbc_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_connect()
{
return @odbc_connect($this->hostname, $this->username, $this->password);
}
-
+
// --------------------------------------------------------------------
/**
@@ -73,12 +73,12 @@ class CI_DB_odbc_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_pconnect()
{
return @odbc_pconnect($this->hostname, $this->username, $this->password);
}
-
+
// --------------------------------------------------------------------
/**
@@ -102,7 +102,7 @@ class CI_DB_odbc_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_select()
{
// Not needed for ODBC
@@ -126,7 +126,7 @@ class CI_DB_odbc_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Version number query string
*
@@ -146,13 +146,13 @@ class CI_DB_odbc_driver extends CI_DB {
* @access private called by the base class
* @param string an SQL query
* @return resource
- */
+ */
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @odbc_exec($this->conn_id, $sql);
}
-
+
// --------------------------------------------------------------------
/**
@@ -163,7 +163,7 @@ class CI_DB_odbc_driver extends CI_DB {
* @access private called by execute()
* @param string an SQL query
* @return string
- */
+ */
function _prep_query($sql)
{
return $sql;
@@ -175,15 +175,15 @@ class CI_DB_odbc_driver extends CI_DB {
* Begin Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
-
+
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
@@ -204,8 +204,8 @@ class CI_DB_odbc_driver extends CI_DB {
* Commit Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_commit()
{
if ( ! $this->trans_enabled)
@@ -230,8 +230,8 @@ class CI_DB_odbc_driver extends CI_DB {
* Rollback Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_rollback()
{
if ( ! $this->trans_enabled)
@@ -265,16 +265,16 @@ class CI_DB_odbc_driver extends CI_DB {
if (is_array($str))
{
foreach($str as $key => $val)
- {
+ {
$str[$key] = $this->escape_str($val, $like);
- }
-
- return $str;
- }
-
+ }
+
+ return $str;
+ }
+
// ODBC doesn't require escaping
$str = remove_invisible_characters($str);
-
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
@@ -282,10 +282,10 @@ class CI_DB_odbc_driver extends CI_DB {
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
/**
@@ -298,7 +298,7 @@ class CI_DB_odbc_driver extends CI_DB {
{
return @odbc_num_rows($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -362,10 +362,10 @@ class CI_DB_odbc_driver extends CI_DB {
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
return FALSE; // not currently supported
}
-
+
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -410,7 +410,7 @@ class CI_DB_odbc_driver extends CI_DB {
{
return odbc_errormsg($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -446,26 +446,26 @@ class CI_DB_odbc_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
-
+ $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
- }
+ }
}
-
+
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
+ $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
-
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
-
+
// --------------------------------------------------------------------
/**
@@ -484,12 +484,12 @@ class CI_DB_odbc_driver extends CI_DB {
{
$tables = array($tables);
}
-
+
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
-
+
/**
* Insert statement
*
@@ -502,10 +502,10 @@ class CI_DB_odbc_driver extends CI_DB {
* @return string
*/
function _insert($table, $keys, $values)
- {
+ {
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
-
+
// --------------------------------------------------------------------
/**
@@ -527,21 +527,21 @@ class CI_DB_odbc_driver extends CI_DB {
{
$valstr[] = $key." = ".$val;
}
-
+
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
+
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
-
+
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -554,12 +554,12 @@ class CI_DB_odbc_driver extends CI_DB {
* @access public
* @param string the table name
* @return string
- */
+ */
function _truncate($table)
{
return $this->_delete($table);
}
-
+
// --------------------------------------------------------------------
/**
@@ -572,7 +572,7 @@ class CI_DB_odbc_driver extends CI_DB {
* @param array the where clause
* @param string the limit clause
* @return string
- */
+ */
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -590,7 +590,7 @@ class CI_DB_odbc_driver extends CI_DB {
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
return "DELETE FROM ".$table.$conditions.$limit;
}
@@ -627,7 +627,7 @@ class CI_DB_odbc_driver extends CI_DB {
@odbc_close($conn_id);
}
-
+
}
diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
index 1ae559b6e..49a2401f1 100644
--- a/system/database/drivers/odbc/odbc_forge.php
+++ b/system/database/drivers/odbc/odbc_forge.php
@@ -54,7 +54,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
function _drop_database($name)
{
// ODBC has no "drop database" command since it's
- // designed to connect to an existing database
+ // designed to connect to an existing database
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -78,12 +78,12 @@ class CI_DB_odbc_forge extends CI_DB_forge {
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
-
+
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
-
+
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
@@ -99,41 +99,41 @@ class CI_DB_odbc_forge extends CI_DB_forge {
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
-
+
$sql .= "\n\t".$this->db->_protect_identifiers($field);
-
+
$sql .= ' '.$attributes['TYPE'];
-
+
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
-
+
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
-
+
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
-
+
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
- $sql .= ' NOT NULL';
+ $sql .= ' NOT NULL';
}
-
+
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
-
+
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
@@ -146,24 +146,24 @@ class CI_DB_odbc_forge extends CI_DB_forge {
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
-
+
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
-
+
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
}
}
-
+
$sql .= "\n)";
return $sql;
@@ -179,7 +179,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
*/
function _drop_table($table)
{
- // Not a supported ODBC feature
+ // Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -235,9 +235,9 @@ class CI_DB_odbc_forge extends CI_DB_forge {
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
-
+
return $sql;
-
+
}
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index 5ae46df62..e2dc8415f 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -25,7 +25,7 @@
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_odbc_result extends CI_DB_result {
-
+
/**
* Number of rows in the result set
*
@@ -36,7 +36,7 @@ class CI_DB_odbc_result extends CI_DB_result {
{
return @odbc_num_rows($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -65,9 +65,9 @@ class CI_DB_odbc_result extends CI_DB_result {
$field_names = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
- $field_names[] = odbc_field_name($this->result_id, $i);
+ $field_names[] = odbc_field_name($this->result_id, $i);
}
-
+
return $field_names;
}
@@ -86,16 +86,16 @@ class CI_DB_odbc_result extends CI_DB_result {
$retval = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
- $F = new stdClass();
- $F->name = odbc_field_name($this->result_id, $i);
- $F->type = odbc_field_type($this->result_id, $i);
+ $F = new stdClass();
+ $F->name = odbc_field_name($this->result_id, $i);
+ $F->type = odbc_field_type($this->result_id, $i);
$F->max_length = odbc_field_len($this->result_id, $i);
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
-
+
return $retval;
}
@@ -105,7 +105,7 @@ class CI_DB_odbc_result extends CI_DB_result {
* Free the result
*
* @return null
- */
+ */
function free_result()
{
if (is_resource($this->result_id))
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index 5b874d88f..deeb0320a 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -32,7 +32,7 @@ class CI_DB_odbc_utility extends CI_DB_utility {
*/
function _list_databases()
{
- // Not sure if ODBC lets you list all databases...
+ // Not sure if ODBC lets you list all databases...
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -53,7 +53,7 @@ class CI_DB_odbc_utility extends CI_DB_utility {
*/
function _optimize_table($table)
{
- // Not a supported ODBC feature
+ // Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -74,7 +74,7 @@ class CI_DB_odbc_utility extends CI_DB_utility {
*/
function _repair_table($table)
{
- // Not a supported ODBC feature
+ // Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 9f991e4a0..cf865432b 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -31,7 +31,7 @@
class CI_DB_postgre_driver extends CI_DB {
var $dbdriver = 'postgre';
-
+
var $_escape_char = '"';
// clause and character used for LIKE escape sequences
@@ -51,7 +51,7 @@ class CI_DB_postgre_driver extends CI_DB {
*
* @access private
* @return string
- */
+ */
function _connect_string()
{
$components = array(
@@ -61,7 +61,7 @@ class CI_DB_postgre_driver extends CI_DB {
'username' => 'user',
'password' => 'password'
);
-
+
$connect_string = "";
foreach ($components as $key => $val)
{
@@ -80,9 +80,9 @@ class CI_DB_postgre_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_connect()
- {
+ {
return @pg_connect($this->_connect_string());
}
@@ -93,12 +93,12 @@ class CI_DB_postgre_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_pconnect()
{
return @pg_pconnect($this->_connect_string());
}
-
+
// --------------------------------------------------------------------
/**
@@ -125,7 +125,7 @@ class CI_DB_postgre_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_select()
{
// Not needed for Postgre so we'll return TRUE
@@ -149,7 +149,7 @@ class CI_DB_postgre_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Version number query string
*
@@ -169,13 +169,13 @@ class CI_DB_postgre_driver extends CI_DB {
* @access private called by the base class
* @param string an SQL query
* @return resource
- */
+ */
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @pg_query($this->conn_id, $sql);
}
-
+
// --------------------------------------------------------------------
/**
@@ -186,7 +186,7 @@ class CI_DB_postgre_driver extends CI_DB {
* @access private called by execute()
* @param string an SQL query
* @return string
- */
+ */
function _prep_query($sql)
{
return $sql;
@@ -198,15 +198,15 @@ class CI_DB_postgre_driver extends CI_DB {
* Begin Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
-
+
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
@@ -227,8 +227,8 @@ class CI_DB_postgre_driver extends CI_DB {
* Commit Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_commit()
{
if ( ! $this->trans_enabled)
@@ -251,8 +251,8 @@ class CI_DB_postgre_driver extends CI_DB {
* Rollback Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_rollback()
{
if ( ! $this->trans_enabled)
@@ -284,15 +284,15 @@ class CI_DB_postgre_driver extends CI_DB {
if (is_array($str))
{
foreach($str as $key => $val)
- {
+ {
$str[$key] = $this->escape_str($val, $like);
- }
-
- return $str;
- }
+ }
+
+ return $str;
+ }
$str = pg_escape_string($str);
-
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
@@ -300,10 +300,10 @@ class CI_DB_postgre_driver extends CI_DB {
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
/**
@@ -316,7 +316,7 @@ class CI_DB_postgre_driver extends CI_DB {
{
return @pg_affected_rows($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -329,10 +329,10 @@ class CI_DB_postgre_driver extends CI_DB {
{
$v = $this->_version();
$v = $v['server'];
-
+
$table = func_num_args() > 0 ? func_get_arg(0) : null;
$column = func_num_args() > 1 ? func_get_arg(1) : null;
-
+
if ($table == null && $v >= '8.1')
{
$sql='SELECT LASTVAL() as ins_id';
@@ -400,17 +400,17 @@ class CI_DB_postgre_driver extends CI_DB {
* @return string
*/
function _list_tables($prefix_limit = FALSE)
- {
- $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
-
+ {
+ $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
+
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
$sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
-
+
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -455,7 +455,7 @@ class CI_DB_postgre_driver extends CI_DB {
{
return pg_last_error($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -491,26 +491,26 @@ class CI_DB_postgre_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
-
+ $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
- }
+ }
}
-
+
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
+ $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
-
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
-
+
// --------------------------------------------------------------------
/**
@@ -529,12 +529,12 @@ class CI_DB_postgre_driver extends CI_DB {
{
$tables = array($tables);
}
-
+
return implode(', ', $tables);
}
// --------------------------------------------------------------------
-
+
/**
* Insert statement
*
@@ -547,10 +547,10 @@ class CI_DB_postgre_driver extends CI_DB {
* @return string
*/
function _insert($table, $keys, $values)
- {
+ {
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
-
+
// --------------------------------------------------------------------
/**
@@ -572,17 +572,17 @@ class CI_DB_postgre_driver extends CI_DB {
{
$valstr[] = $key." = ".$val;
}
-
+
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
+
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
-
+
return $sql;
}
@@ -598,12 +598,12 @@ class CI_DB_postgre_driver extends CI_DB {
* @access public
* @param string the table name
* @return string
- */
+ */
function _truncate($table)
{
return "TRUNCATE ".$table;
}
-
+
// --------------------------------------------------------------------
/**
@@ -616,7 +616,7 @@ class CI_DB_postgre_driver extends CI_DB {
* @param array the where clause
* @param string the limit clause
* @return string
- */
+ */
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -634,7 +634,7 @@ class CI_DB_postgre_driver extends CI_DB {
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
return "DELETE FROM ".$table.$conditions.$limit;
}
@@ -651,14 +651,14 @@ class CI_DB_postgre_driver extends CI_DB {
* @return string
*/
function _limit($sql, $limit, $offset)
- {
+ {
$sql .= "LIMIT ".$limit;
-
+
if ($offset > 0)
{
$sql .= " OFFSET ".$offset;
}
-
+
return $sql;
}
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index c98ef425d..12eef2923 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -66,12 +66,12 @@ class CI_DB_postgre_forge extends CI_DB_forge {
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
-
+
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
-
+
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
@@ -87,41 +87,41 @@ class CI_DB_postgre_forge extends CI_DB_forge {
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
-
+
$sql .= "\n\t".$this->db->_protect_identifiers($field);
-
+
$sql .= ' '.$attributes['TYPE'];
-
+
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
-
+
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
-
+
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
-
+
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
- $sql .= ' NOT NULL';
+ $sql .= ' NOT NULL';
}
-
+
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
-
+
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
@@ -134,20 +134,20 @@ class CI_DB_postgre_forge extends CI_DB_forge {
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
-
+
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
-
+
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
}
}
@@ -218,9 +218,9 @@ class CI_DB_postgre_forge extends CI_DB_forge {
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
-
+
return $sql;
-
+
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php
index 545f413e8..b60ad7dd3 100644
--- a/system/database/drivers/postgre/postgre_result.php
+++ b/system/database/drivers/postgre/postgre_result.php
@@ -36,7 +36,7 @@ class CI_DB_postgre_result extends CI_DB_result {
{
return @pg_num_rows($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -67,7 +67,7 @@ class CI_DB_postgre_result extends CI_DB_result {
{
$field_names[] = pg_field_name($this->result_id, $i);
}
-
+
return $field_names;
}
@@ -86,16 +86,16 @@ class CI_DB_postgre_result extends CI_DB_result {
$retval = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
- $F = new stdClass();
- $F->name = pg_field_name($this->result_id, $i);
- $F->type = pg_field_type($this->result_id, $i);
+ $F = new stdClass();
+ $F->name = pg_field_name($this->result_id, $i);
+ $F->type = pg_field_type($this->result_id, $i);
$F->max_length = pg_field_size($this->result_id, $i);
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
-
+
return $retval;
}
@@ -105,7 +105,7 @@ class CI_DB_postgre_result extends CI_DB_result {
* Free the result
*
* @return null
- */
+ */
function free_result()
{
if (is_resource($this->result_id))
@@ -146,7 +146,7 @@ class CI_DB_postgre_result extends CI_DB_result {
{
return pg_fetch_assoc($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -161,7 +161,7 @@ class CI_DB_postgre_result extends CI_DB_result {
{
return pg_fetch_object($this->result_id);
}
-
+
}
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index c08ed2a56..ea0583e9e 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -33,14 +33,14 @@
class CI_DB_sqlite_driver extends CI_DB {
var $dbdriver = 'sqlite';
-
+
// The character used to escape with - not needed for SQLite
var $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " ESCAPE '%s' ";
+ var $_like_escape_str = " ESCAPE '%s' ";
var $_like_escape_chr = '!';
-
+
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
@@ -54,24 +54,24 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_connect()
{
if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error))
{
log_message('error', $error);
-
+
if ($this->db_debug)
{
$this->display_error($error, '', TRUE);
}
-
+
return FALSE;
}
-
+
return $conn_id;
}
-
+
// --------------------------------------------------------------------
/**
@@ -79,24 +79,24 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_pconnect()
{
if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error))
{
log_message('error', $error);
-
+
if ($this->db_debug)
{
$this->display_error($error, '', TRUE);
}
-
+
return FALSE;
}
-
+
return $conn_id;
}
-
+
// --------------------------------------------------------------------
/**
@@ -120,7 +120,7 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_select()
{
return TRUE;
@@ -143,7 +143,7 @@ class CI_DB_sqlite_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Version number query string
*
@@ -154,7 +154,7 @@ class CI_DB_sqlite_driver extends CI_DB {
{
return sqlite_libversion();
}
-
+
// --------------------------------------------------------------------
/**
@@ -163,13 +163,13 @@ class CI_DB_sqlite_driver extends CI_DB {
* @access private called by the base class
* @param string an SQL query
* @return resource
- */
+ */
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @sqlite_query($this->conn_id, $sql);
}
-
+
// --------------------------------------------------------------------
/**
@@ -180,7 +180,7 @@ class CI_DB_sqlite_driver extends CI_DB {
* @access private called by execute()
* @param string an SQL query
* @return string
- */
+ */
function _prep_query($sql)
{
return $sql;
@@ -192,15 +192,15 @@ class CI_DB_sqlite_driver extends CI_DB {
* Begin Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
-
+
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
@@ -222,8 +222,8 @@ class CI_DB_sqlite_driver extends CI_DB {
* Commit Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_commit()
{
if ( ! $this->trans_enabled)
@@ -247,8 +247,8 @@ class CI_DB_sqlite_driver extends CI_DB {
* Rollback Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_rollback()
{
if ( ! $this->trans_enabled)
@@ -265,7 +265,7 @@ class CI_DB_sqlite_driver extends CI_DB {
$this->simple_query('ROLLBACK');
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -281,15 +281,15 @@ class CI_DB_sqlite_driver extends CI_DB {
if (is_array($str))
{
foreach($str as $key => $val)
- {
+ {
$str[$key] = $this->escape_str($val, $like);
- }
-
- return $str;
- }
-
+ }
+
+ return $str;
+ }
+
$str = sqlite_escape_string($str);
-
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
@@ -297,10 +297,10 @@ class CI_DB_sqlite_driver extends CI_DB {
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
/**
@@ -313,7 +313,7 @@ class CI_DB_sqlite_driver extends CI_DB {
{
return sqlite_changes($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -347,7 +347,7 @@ class CI_DB_sqlite_driver extends CI_DB {
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
-
+
if ($query->num_rows() == 0)
{
return 0;
@@ -424,7 +424,7 @@ class CI_DB_sqlite_driver extends CI_DB {
{
return sqlite_error_string(sqlite_last_error($this->conn_id));
}
-
+
// --------------------------------------------------------------------
/**
@@ -460,26 +460,26 @@ class CI_DB_sqlite_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
-
+ $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
- }
+ }
}
-
+
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
+ $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
-
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
-
+
// --------------------------------------------------------------------
/**
@@ -498,12 +498,12 @@ class CI_DB_sqlite_driver extends CI_DB {
{
$tables = array($tables);
}
-
+
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
-
+
/**
* Insert statement
*
@@ -516,10 +516,10 @@ class CI_DB_sqlite_driver extends CI_DB {
* @return string
*/
function _insert($table, $keys, $values)
- {
+ {
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
-
+
// --------------------------------------------------------------------
/**
@@ -541,21 +541,21 @@ class CI_DB_sqlite_driver extends CI_DB {
{
$valstr[] = $key." = ".$val;
}
-
+
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
+
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
-
+
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -568,12 +568,12 @@ class CI_DB_sqlite_driver extends CI_DB {
* @access public
* @param string the table name
* @return string
- */
+ */
function _truncate($table)
{
return $this->_delete($table);
}
-
+
// --------------------------------------------------------------------
/**
@@ -586,7 +586,7 @@ class CI_DB_sqlite_driver extends CI_DB {
* @param array the where clause
* @param string the limit clause
* @return string
- */
+ */
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -604,10 +604,10 @@ class CI_DB_sqlite_driver extends CI_DB {
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
return "DELETE FROM ".$table.$conditions.$limit;
}
-
+
// --------------------------------------------------------------------
/**
@@ -622,7 +622,7 @@ class CI_DB_sqlite_driver extends CI_DB {
* @return string
*/
function _limit($sql, $limit, $offset)
- {
+ {
if ($offset == 0)
{
$offset = '';
@@ -631,7 +631,7 @@ class CI_DB_sqlite_driver extends CI_DB {
{
$offset .= ", ";
}
-
+
return $sql."LIMIT ".$offset.$limit;
}
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
index 53b20a3c7..7b5c894f6 100644
--- a/system/database/drivers/sqlite/sqlite_forge.php
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -75,13 +75,13 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
-
+
// IF NOT EXISTS added to SQLite in 3.3.0
if ($if_not_exists === TRUE && version_compare($this->db->_version(), '3.3.0', '>=') === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
-
+
$sql .= $this->db->_escape_identifiers($table)."(";
$current_field_count = 0;
@@ -97,41 +97,41 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
-
+
$sql .= "\n\t".$this->db->_protect_identifiers($field);
-
+
$sql .= ' '.$attributes['TYPE'];
-
+
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
-
+
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
-
+
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
-
+
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
- $sql .= ' NOT NULL';
+ $sql .= ' NOT NULL';
}
-
+
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
-
+
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
@@ -151,13 +151,13 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
-
+
$sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")";
}
}
@@ -237,9 +237,9 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
-
+
return $sql;
-
+
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php
index 7b0631221..fd6d83d0c 100644
--- a/system/database/drivers/sqlite/sqlite_result.php
+++ b/system/database/drivers/sqlite/sqlite_result.php
@@ -25,7 +25,7 @@
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_sqlite_result extends CI_DB_result {
-
+
/**
* Number of rows in the result set
*
@@ -36,7 +36,7 @@ class CI_DB_sqlite_result extends CI_DB_result {
{
return @sqlite_num_rows($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -67,7 +67,7 @@ class CI_DB_sqlite_result extends CI_DB_result {
{
$field_names[] = sqlite_field_name($this->result_id, $i);
}
-
+
return $field_names;
}
@@ -86,16 +86,16 @@ class CI_DB_sqlite_result extends CI_DB_result {
$retval = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
- $F = new stdClass();
- $F->name = sqlite_field_name($this->result_id, $i);
- $F->type = 'varchar';
+ $F = new stdClass();
+ $F->name = sqlite_field_name($this->result_id, $i);
+ $F->type = 'varchar';
$F->max_length = 0;
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
-
+
return $retval;
}
@@ -105,7 +105,7 @@ class CI_DB_sqlite_result extends CI_DB_result {
* Free the result
*
* @return null
- */
+ */
function free_result()
{
// Not implemented in SQLite
@@ -142,7 +142,7 @@ class CI_DB_sqlite_result extends CI_DB_result {
{
return sqlite_fetch_array($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -168,7 +168,7 @@ class CI_DB_sqlite_result extends CI_DB_result {
return $obj;
} else {
return NULL;
- }
+ }
}
}