

Public Member Functions | |
| db_connect () | |
| Non-persistent database connection. | |
| db_pconnect () | |
| Persistent database connection. | |
| db_select () | |
| Select the database. | |
| _db_set_charset ($charset, $collation) | |
| Set client character set. | |
| _version () | |
| Version number query string. | |
| _execute ($sql) | |
| Execute the query. | |
| _prep_query ($sql) | |
| Prep the query. | |
| trans_begin ($test_mode=FALSE) | |
| Begin Transaction. | |
| trans_commit () | |
| Commit Transaction. | |
| trans_rollback () | |
| Rollback Transaction. | |
| escape_str ($str) | |
| Escape String. | |
| affected_rows () | |
| Affected Rows. | |
| insert_id () | |
| Insert ID. | |
| count_all ($table= '') | |
| "Count All" query | |
| _list_tables ($prefix_limit=FALSE) | |
| List table query. | |
| _list_columns ($table= '') | |
| Show column query. | |
| _field_data ($table) | |
| Field data query. | |
| _error_message () | |
| The error message string. | |
| _error_number () | |
| The error message number. | |
| _escape_identifiers ($item) | |
| Escape the SQL Identifiers. | |
| _from_tables ($tables) | |
| From Tables. | |
| _insert ($table, $keys, $values) | |
| Insert statement. | |
| _update ($table, $values, $where, $orderby=array(), $limit=FALSE) | |
| Update statement. | |
| _truncate ($table) | |
| Truncate statement. | |
| _delete ($table, $where=array(), $like=array(), $limit=FALSE) | |
| Delete statement. | |
| _limit ($sql, $limit, $offset) | |
| Limit string. | |
| _close ($conn_id) | |
| Close DB Connection. | |
Public Attributes | |
| $dbdriver = 'mysqli' | |
| $_escape_char = '`' | |
| $_count_string = "SELECT COUNT(*) AS " | |
| The syntax to count rows is slightly different across different database engines, so this string appears in each driver and is used for the count_all() and count_all_results() functions. | |
| $_random_keyword = ' RAND()' | |
| $delete_hack = TRUE | |
| Whether to use the MySQL "delete hack" which allows the number of affected rows to be shown. | |
Definition at line 31 of file mysqli_driver.php.
| CI_DB_mysqli_driver::_close | ( | $ | conn_id | ) |
Close DB Connection.
public
| resource |
Definition at line 596 of file mysqli_driver.php.
| CI_DB_mysqli_driver::_db_set_charset | ( | $ | charset, | |
| $ | collation | |||
| ) |
Set client character set.
private
| string | ||
| string |
Definition at line 102 of file mysqli_driver.php.
References escape_str().
00103 { 00104 return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'"); 00105 }

| CI_DB_mysqli_driver::_delete | ( | $ | table, | |
| $ | where = array(), |
|||
| $ | like = array(), |
|||
| $ | limit = FALSE | |||
| ) |
Delete statement.
Generates a platform-specific delete string from the supplied data
public
| string | the table name | |
| array | the where clause | |
| string | the limit clause |
Definition at line 541 of file mysqli_driver.php.
00542 { 00543 $conditions = ''; 00544 00545 if (count($where) > 0 OR count($like) > 0) 00546 { 00547 $conditions = "\nWHERE "; 00548 $conditions .= implode("\n", $this->ar_where); 00549 00550 if (count($where) > 0 && count($like) > 0) 00551 { 00552 $conditions .= " AND "; 00553 } 00554 $conditions .= implode("\n", $like); 00555 } 00556 00557 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; 00558 00559 return "DELETE FROM ".$table.$conditions.$limit; 00560 }
| CI_DB_mysqli_driver::_error_message | ( | ) |
| CI_DB_mysqli_driver::_error_number | ( | ) |
| CI_DB_mysqli_driver::_escape_identifiers | ( | $ | item | ) |
Escape the SQL Identifiers.
This function escapes column and table names
private
| string |
Definition at line 414 of file mysqli_driver.php.
00415 { 00416 if ($this->_escape_char == '') 00417 { 00418 return $item; 00419 } 00420 00421 if (strpos($item, '.') !== FALSE) 00422 { 00423 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; 00424 } 00425 else 00426 { 00427 $str = $this->_escape_char.$item.$this->_escape_char; 00428 } 00429 00430 // remove duplicates if the user already included the escape 00431 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); 00432 }
| CI_DB_mysqli_driver::_execute | ( | $ | sql | ) |
Execute the query.
private called by the base class
| string | an SQL query |
Definition at line 129 of file mysqli_driver.php.
References _prep_query().
00130 { 00131 $sql = $this->_prep_query($sql); 00132 $result = @mysqli_query($this->conn_id, $sql); 00133 return $result; 00134 }

| CI_DB_mysqli_driver::_field_data | ( | $ | table | ) |
Field data query.
Generates a platform-specific query so that the column data can be retrieved
public
| string | the table name |
Definition at line 372 of file mysqli_driver.php.
| CI_DB_mysqli_driver::_from_tables | ( | $ | tables | ) |
From Tables.
This function implicitly groups FROM tables so there is no confusion about operator precedence in harmony with SQL standards
public
| type |
Definition at line 446 of file mysqli_driver.php.
00447 { 00448 if ( ! is_array($tables)) 00449 { 00450 $tables = array($tables); 00451 } 00452 00453 return '('.implode(', ', $tables).')'; 00454 }
| CI_DB_mysqli_driver::_insert | ( | $ | table, | |
| $ | keys, | |||
| $ | values | |||
| ) |
Insert statement.
Generates a platform-specific insert string from the supplied data
public
| string | the table name | |
| array | the insert keys | |
| array | the insert values |
Definition at line 469 of file mysqli_driver.php.
00470 { 00471 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; 00472 }
| CI_DB_mysqli_driver::_limit | ( | $ | sql, | |
| $ | limit, | |||
| $ | offset | |||
| ) |
Limit string.
Generates a platform-specific LIMIT clause
public
| string | the sql query string | |
| integer | the number of rows to limit the query to | |
| integer | the offset value |
Definition at line 575 of file mysqli_driver.php.
00576 { 00577 $sql .= "LIMIT ".$limit; 00578 00579 if ($offset > 0) 00580 { 00581 $sql .= " OFFSET ".$offset; 00582 } 00583 00584 return $sql; 00585 }
| CI_DB_mysqli_driver::_list_columns | ( | $ | table = '' |
) |
Show column query.
Generates a platform-specific query string so that the column names can be fetched
public
| string | the table name |
Definition at line 356 of file mysqli_driver.php.
| CI_DB_mysqli_driver::_list_tables | ( | $ | prefix_limit = FALSE |
) |
List table query.
Generates a platform-specific query string so that the table names can be fetched
private
| boolean |
Definition at line 333 of file mysqli_driver.php.
00334 { 00335 $sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char; 00336 00337 if ($prefix_limit !== FALSE AND $this->dbprefix != '') 00338 { 00339 $sql .= " LIKE '".$this->dbprefix."%'"; 00340 } 00341 00342 return $sql; 00343 }
| CI_DB_mysqli_driver::_prep_query | ( | $ | sql | ) |
Prep the query.
If needed, each database adapter can prep the query string
private called by execute()
| string | an SQL query |
Definition at line 147 of file mysqli_driver.php.
Referenced by _execute().
00148 { 00149 // "DELETE FROM TABLE" returns 0 affected rows This hack modifies 00150 // the query so that it returns the number of affected rows 00151 if ($this->delete_hack === TRUE) 00152 { 00153 if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql)) 00154 { 00155 $sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql); 00156 } 00157 } 00158 00159 return $sql; 00160 }

| CI_DB_mysqli_driver::_truncate | ( | $ | table | ) |
Truncate statement.
Generates a platform-specific truncate string from the supplied data If the database does not support the truncate() command This function maps to "DELETE FROM table"
public
| string | the table name |
Definition at line 523 of file mysqli_driver.php.
| CI_DB_mysqli_driver::_update | ( | $ | table, | |
| $ | values, | |||
| $ | where, | |||
| $ | orderby = array(), |
|||
| $ | limit = FALSE | |||
| ) |
Update statement.
Generates a platform-specific update string from the supplied data
public
| string | the table name | |
| array | the update data | |
| array | the where clause | |
| array | the orderby clause | |
| array | the limit clause |
Definition at line 489 of file mysqli_driver.php.
00490 { 00491 foreach($values as $key => $val) 00492 { 00493 $valstr[] = $key." = ".$val; 00494 } 00495 00496 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; 00497 00498 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; 00499 00500 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); 00501 00502 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; 00503 00504 $sql .= $orderby.$limit; 00505 00506 return $sql; 00507 }
| CI_DB_mysqli_driver::_version | ( | ) |
Version number query string.
public
Definition at line 115 of file mysqli_driver.php.
| CI_DB_mysqli_driver::affected_rows | ( | ) |
| CI_DB_mysqli_driver::count_all | ( | $ | table = '' |
) |
"Count All" query
Generates a platform-specific query string that counts all records in the specified database
public
| string |
Definition at line 308 of file mysqli_driver.php.
00309 { 00310 if ($table == '') 00311 return '0'; 00312 00313 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows'). " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); 00314 00315 if ($query->num_rows() == 0) 00316 return '0'; 00317 00318 $row = $query->row(); 00319 return $row->numrows; 00320 }
| CI_DB_mysqli_driver::db_connect | ( | ) |
Non-persistent database connection.
private called by the base class
Definition at line 61 of file mysqli_driver.php.
Referenced by db_pconnect().
00062 { 00063 return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port); 00064 }

| CI_DB_mysqli_driver::db_pconnect | ( | ) |
Persistent database connection.
private called by the base class
Definition at line 74 of file mysqli_driver.php.
References db_connect().
00075 { 00076 return $this->db_connect(); 00077 }

| CI_DB_mysqli_driver::db_select | ( | ) |
Select the database.
private called by the base class
Definition at line 87 of file mysqli_driver.php.
| CI_DB_mysqli_driver::escape_str | ( | $ | str | ) |
Escape String.
public
| string |
Definition at line 254 of file mysqli_driver.php.
Referenced by _db_set_charset().
00255 { 00256 if (function_exists('mysqli_real_escape_string') AND is_object($this->conn_id)) 00257 { 00258 return mysqli_real_escape_string($this->conn_id, $str); 00259 } 00260 elseif (function_exists('mysql_escape_string')) 00261 { 00262 return mysql_escape_string($str); 00263 } 00264 else 00265 { 00266 return addslashes($str); 00267 } 00268 }

| CI_DB_mysqli_driver::insert_id | ( | ) |
| CI_DB_mysqli_driver::trans_begin | ( | $ | test_mode = FALSE |
) |
Begin Transaction.
public
Definition at line 170 of file mysqli_driver.php.
00171 { 00172 if ( ! $this->trans_enabled) 00173 { 00174 return TRUE; 00175 } 00176 00177 // When transactions are nested we only begin/commit/rollback the outermost ones 00178 if ($this->_trans_depth > 0) 00179 { 00180 return TRUE; 00181 } 00182 00183 // Reset the transaction failure flag. 00184 // If the $test_mode flag is set to TRUE transactions will be rolled back 00185 // even if the queries produce a successful result. 00186 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; 00187 00188 $this->simple_query('SET AUTOCOMMIT=0'); 00189 $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK 00190 return TRUE; 00191 }
| CI_DB_mysqli_driver::trans_commit | ( | ) |
Commit Transaction.
public
Definition at line 201 of file mysqli_driver.php.
00202 { 00203 if ( ! $this->trans_enabled) 00204 { 00205 return TRUE; 00206 } 00207 00208 // When transactions are nested we only begin/commit/rollback the outermost ones 00209 if ($this->_trans_depth > 0) 00210 { 00211 return TRUE; 00212 } 00213 00214 $this->simple_query('COMMIT'); 00215 $this->simple_query('SET AUTOCOMMIT=1'); 00216 return TRUE; 00217 }
| CI_DB_mysqli_driver::trans_rollback | ( | ) |
Rollback Transaction.
public
Definition at line 227 of file mysqli_driver.php.
00228 { 00229 if ( ! $this->trans_enabled) 00230 { 00231 return TRUE; 00232 } 00233 00234 // When transactions are nested we only begin/commit/rollback the outermost ones 00235 if ($this->_trans_depth > 0) 00236 { 00237 return TRUE; 00238 } 00239 00240 $this->simple_query('ROLLBACK'); 00241 $this->simple_query('SET AUTOCOMMIT=1'); 00242 return TRUE; 00243 }
| CI_DB_mysqli_driver::$_count_string = "SELECT COUNT(*) AS " |
The syntax to count rows is slightly different across different database engines, so this string appears in each driver and is used for the count_all() and count_all_results() functions.
Definition at line 43 of file mysqli_driver.php.
| CI_DB_mysqli_driver::$_escape_char = '`' |
Definition at line 36 of file mysqli_driver.php.
| CI_DB_mysqli_driver::$_random_keyword = ' RAND()' |
Definition at line 44 of file mysqli_driver.php.
| CI_DB_mysqli_driver::$dbdriver = 'mysqli' |
Definition at line 33 of file mysqli_driver.php.
| CI_DB_mysqli_driver::$delete_hack = TRUE |
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.
Definition at line 51 of file mysqli_driver.php.