summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mysqli
diff options
context:
space:
mode:
authorPascal Kriete <pascal.kriete@ellislab.com>2010-11-04 22:59:52 +0100
committerPascal Kriete <pascal.kriete@ellislab.com>2010-11-04 22:59:52 +0100
commite917f9be8b05c81357c1c2c9730d5060685d644d (patch)
treeb6a7d5ce8ba57b69ba61454f77829b04f2ce5974 /system/database/drivers/mysqli
parent5b2d2da5ae2e97043c6bef53e565d30e50196e2b (diff)
parente1f6e9ddff788f6a154f5f35dc117d14aeb0c484 (diff)
Automated merge with http://hg.ellislab.com/CodeIgniter2
Diffstat (limited to 'system/database/drivers/mysqli')
-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
4 files changed, 89 insertions, 89 deletions
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";
}
-
+
// --------------------------------------------------------------------
/**