6,7 → 6,7 |
* The PEAR DB driver for PHP's mysqli extension |
* for interacting with MySQL databases |
* |
* PHP versions 4 and 5 |
* PHP version 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
17,9 → 17,9 |
* @category Database |
* @package DB |
* @author Daniel Convissor <danielc@php.net> |
* @copyright 1997-2005 The PHP Group |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: mysqli.php,v 1.69 2005/03/04 23:12:36 danielc Exp $ |
* @version CVS: $Id$ |
* @link http://pear.php.net/package/DB |
*/ |
|
41,9 → 41,9 |
* @category Database |
* @package DB |
* @author Daniel Convissor <danielc@php.net> |
* @copyright 1997-2005 The PHP Group |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.7.6 |
* @version Release: 1.9.2 |
* @link http://pear.php.net/package/DB |
* @since Class functional since Release 1.6.3 |
*/ |
114,6 → 114,9 |
1146 => DB_ERROR_NOSUCHTABLE, |
1216 => DB_ERROR_CONSTRAINT, |
1217 => DB_ERROR_CONSTRAINT, |
1356 => DB_ERROR_DIVZERO, |
1451 => DB_ERROR_CONSTRAINT, |
1452 => DB_ERROR_CONSTRAINT, |
); |
|
/** |
210,6 → 213,10 |
MYSQLI_TYPE_VAR_STRING => 'varchar', |
MYSQLI_TYPE_STRING => 'char', |
MYSQLI_TYPE_GEOMETRY => 'geometry', |
/* These constants are conditionally compiled in ext/mysqli, so we'll |
* define them by number rather than constant. */ |
16 => 'bit', |
246 => 'decimal', |
); |
|
|
217,13 → 224,13 |
// {{{ constructor |
|
/** |
* This constructor calls <kbd>$this->DB_common()</kbd> |
* This constructor calls <kbd>parent::__construct()</kbd> |
* |
* @return void |
*/ |
function DB_mysqli() |
function __construct() |
{ |
$this->DB_common(); |
parent::__construct(); |
} |
|
// }}} |
264,7 → 271,7 |
* 'ssl' => true, |
* ); |
* |
* $db =& DB::connect($dsn, $options); |
* $db = DB::connect($dsn, $options); |
* if (PEAR::isError($db)) { |
* die($db->getMessage()); |
* } |
287,10 → 294,10 |
} |
|
$ini = ini_get('track_errors'); |
ini_set('track_errors', 1); |
@ini_set('track_errors', 1); |
$php_errormsg = ''; |
|
if ($this->getOption('ssl') === true) { |
if (((int) $this->getOption('ssl')) === 1) { |
$init = mysqli_init(); |
mysqli_ssl_set( |
$init, |
322,7 → 329,7 |
); |
} |
|
ini_set('track_errors', $ini); |
@ini_set('track_errors', $ini); |
|
if (!$this->connection) { |
if (($err = @mysqli_connect_error()) != '') { |
372,7 → 379,7 |
*/ |
function simpleQuery($query) |
{ |
$ismanip = DB::isManip($query); |
$ismanip = $this->_checkManip($query); |
$this->last_query = $query; |
$query = $this->modifyQuery($query); |
if ($this->_db) { |
490,7 → 497,11 |
*/ |
function freeResult($result) |
{ |
return @mysqli_free_result($result); |
if (! $result instanceof mysqli_result) { |
return false; |
} |
mysqli_free_result($result); |
return true; |
} |
|
// }}} |
626,7 → 637,7 |
*/ |
function affectedRows() |
{ |
if (DB::isManip($this->last_query)) { |
if ($this->_last_query_manip) { |
return @mysqli_affected_rows($this->connection); |
} else { |
return 0; |
823,9 → 834,10 |
|
/** |
* Quotes a string so it can be safely used as a table or column name |
* (WARNING: using names that require this is a REALLY BAD IDEA) |
* |
* MySQL can't handle the backtick character (<kbd>`</kbd>) in |
* table or column names. |
* WARNING: Older versions of MySQL can't handle the backtick |
* character (<kbd>`</kbd>) in table or column names. |
* |
* @param string $str identifier name to be quoted |
* |
836,7 → 848,7 |
*/ |
function quoteIdentifier($str) |
{ |
return '`' . $str . '`'; |
return '`' . str_replace('`', '``', $str) . '`'; |
} |
|
// }}} |
878,7 → 890,7 |
*/ |
function modifyLimitQuery($query, $from, $count, $params = array()) |
{ |
if (DB::isManip($query)) { |
if (DB::isManip($query) || $this->_next_query_manip) { |
return $query . " LIMIT $count"; |
} else { |
return $query . " LIMIT $from, $count"; |
954,6 → 966,13 |
function tableInfo($result, $mode = null) |
{ |
if (is_string($result)) { |
// Fix for bug #11580. |
if ($this->_db) { |
if (!@mysqli_select_db($this->connection, $this->_db)) { |
return $this->mysqliRaiseError(DB_ERROR_NODBSELECTED); |
} |
} |
|
/* |
* Probably received a table name. |
* Create a result resource identifier. |
978,7 → 997,7 |
$got_string = false; |
} |
|
if (!is_a($id, 'mysqli_result')) { |
if (!is_object($id) || !is_a($id, 'mysqli_result')) { |
return $this->mysqliRaiseError(DB_ERROR_NEED_MORE_DATA); |
} |
|
1015,7 → 1034,12 |
'type' => isset($this->mysqli_types[$tmp->type]) |
? $this->mysqli_types[$tmp->type] |
: 'unknown', |
'len' => $tmp->max_length, |
// http://bugs.php.net/?id=36579 |
// Doc Bug #36579: mysqli_fetch_field length handling |
// https://bugs.php.net/bug.php?id=62426 |
// Bug #62426: mysqli_fetch_field_direct returns incorrect |
// length on UTF8 fields |
'len' => $tmp->length, |
'flags' => $flags, |
); |
|