Zeile 6 | Zeile 6 |
---|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* $Id: db_mysql.php 5828 2012-05-08 16:06:16Z Tomm $
| * $Id$
|
*/
class DB_MySQL
| */
class DB_MySQL
|
Zeile 185 | Zeile 185 |
---|
foreach($connections[$type] as $single_connection) { $connect_function = "mysql_connect";
|
foreach($connections[$type] as $single_connection) { $connect_function = "mysql_connect";
|
if($single_connection['pconnect'])
| if(isset($single_connection['pconnect']))
|
{ $connect_function = "mysql_pconnect"; }
|
{ $connect_function = "mysql_pconnect"; }
|
$link = $type."_link";
| $link = "{$type}_link";
|
$this->get_execution_time();
| $this->get_execution_time();
|
Zeile 340 | Zeile 340 |
---|
function explain_query($string, $qtime) { global $plugins;
|
function explain_query($string, $qtime) { global $plugins;
|
| $debug_extra = '';
|
if($plugins->current_hook) { $debug_extra = "<div style=\"float_right\">(Plugin Hook: {$plugins->current_hook})</div>";
| if($plugins->current_hook) { $debug_extra = "<div style=\"float_right\">(Plugin Hook: {$plugins->current_hook})</div>";
|
Zeile 352 | Zeile 354 |
---|
"<td colspan=\"8\" style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#".$this->query_count." - Select Query</strong></div></td>\n". "</tr>\n". "<tr>\n".
|
"<td colspan=\"8\" style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#".$this->query_count." - Select Query</strong></div></td>\n". "</tr>\n". "<tr>\n".
|
"<td colspan=\"8\" style=\"background-color: #fefefe;\"><span style=\"font-family: Courier; font-size: 14px;\">".$string."</span></td>\n".
| "<td colspan=\"8\" style=\"background-color: #fefefe;\"><span style=\"font-family: Courier; font-size: 14px;\">".htmlspecialchars_uni($string)."</span></td>\n".
|
"</tr>\n". "<tr style=\"background-color: #efefef;\">\n". "<td><strong>table</strong></td>\n".
| "</tr>\n". "<tr style=\"background-color: #efefef;\">\n". "<td><strong>table</strong></td>\n".
|
Zeile 391 | Zeile 393 |
---|
$this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n". "<tr>\n". "<td style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#".$this->query_count." - Write Query</strong></div></td>\n".
|
$this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n". "<tr>\n". "<td style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#".$this->query_count." - Write Query</strong></div></td>\n".
|
"</tr>\n".
| "</tr>\n".
|
"<tr style=\"background-color: #fefefe;\">\n". "<td><span style=\"font-family: Courier; font-size: 14px;\">".htmlspecialchars_uni($string)."</span></td>\n". "</tr>\n".
| "<tr style=\"background-color: #fefefe;\">\n". "<td><span style=\"font-family: Courier; font-size: 14px;\">".htmlspecialchars_uni($string)."</span></td>\n". "</tr>\n".
|
Zeile 404 | Zeile 406 |
---|
$this->querylist[$this->query_count]['query'] = $string; $this->querylist[$this->query_count]['time'] = $qtime;
|
$this->querylist[$this->query_count]['query'] = $string; $this->querylist[$this->query_count]['time'] = $qtime;
|
}
| }
|
/** * Return a result array for a query. *
| /** * Return a result array for a query. *
|
Zeile 414 | Zeile 416 |
---|
* @param constant The type of array to return. * @return array The array of results. */
|
* @param constant The type of array to return. * @return array The array of results. */
|
function fetch_array($query)
| function fetch_array($query, $resulttype=MYSQL_ASSOC)
|
{
|
{
|
$array = mysql_fetch_assoc($query);
| switch($resulttype) { case MYSQL_NUM: case MYSQL_BOTH: break; default: $resulttype = MYSQL_ASSOC; break; }
$array = mysql_fetch_array($query, $resulttype);
|
return $array;
|
return $array;
|
}
| }
|
/** * Return a specific field from a query.
| /** * Return a specific field from a query.
|
Zeile 442 | Zeile 455 |
---|
/** * Moves internal row pointer to the next row
|
/** * Moves internal row pointer to the next row
|
* * @param resource The query ID.
| * * @param resource The query ID.
|
* @param int The pointer to move the row to. */ function data_seek($query, $row)
| * @param int The pointer to move the row to. */ function data_seek($query, $row)
|
Zeile 456 | Zeile 469 |
---|
* * @param resource The query ID. * @return int The number of rows in the result.
|
* * @param resource The query ID. * @return int The number of rows in the result.
|
*/
| */
|
function num_rows($query) { return mysql_num_rows($query);
| function num_rows($query) { return mysql_num_rows($query);
|
Zeile 468 | Zeile 481 |
---|
* @return int The id number. */ function insert_id()
|
* @return int The id number. */ function insert_id()
|
{
| {
|
return mysql_insert_id($this->current_link); }
| return mysql_insert_id($this->current_link); }
|
Zeile 491 | Zeile 504 |
---|
* @return int The error number of the current error. */ function error_number()
|
* @return int The error number of the current error. */ function error_number()
|
{ if($this->current_link) {
| { if($this->current_link) {
|
return @mysql_errno($this->current_link); } else
| return @mysql_errno($this->current_link); } else
|
Zeile 693 | Zeile 706 |
---|
if(isset($options['order_dir'])) { $query .= " ".my_strtoupper($options['order_dir']);
|
if(isset($options['order_dir'])) { $query .= " ".my_strtoupper($options['order_dir']);
|
} }
| } }
|
if(isset($options['limit_start']) && isset($options['limit']))
|
if(isset($options['limit_start']) && isset($options['limit']))
|
{
| {
|
$query .= " LIMIT ".$options['limit_start'].", ".$options['limit'];
|
$query .= " LIMIT ".$options['limit_start'].", ".$options['limit'];
|
}
| }
|
elseif(isset($options['limit'])) { $query .= " LIMIT ".$options['limit']; } return $this->query($query);
|
elseif(isset($options['limit'])) { $query .= " LIMIT ".$options['limit']; } return $this->query($query);
|
}
| }
|
/** * Build an insert query from an array. *
| /** * Build an insert query from an array. *
|
Zeile 714 | Zeile 727 |
---|
* @return int The insert ID if available */ function insert_query($table, $array)
|
* @return int The insert ID if available */ function insert_query($table, $array)
|
{ if(!is_array($array)) { return false;
| { if(!is_array($array)) { return false;
|
} $fields = "`".implode("`,`", array_keys($array))."`"; $values = implode("','", $array);
| } $fields = "`".implode("`,`", array_keys($array))."`"; $values = implode("','", $array);
|
Zeile 729 | Zeile 742 |
---|
return $this->insert_id(); }
|
return $this->insert_id(); }
|
/**
| /**
|
* Build one query for multiple inserts from a multidimensional array. * * @param string The table name to perform the query on.
| * Build one query for multiple inserts from a multidimensional array. * * @param string The table name to perform the query on.
|
Zeile 737 | Zeile 750 |
---|
* @return int The insert ID if available */ function insert_query_multiple($table, $array)
|
* @return int The insert ID if available */ function insert_query_multiple($table, $array)
|
{ if(!is_array($array)) { return false; }
| { if(!is_array($array)) { return false; }
|
// Field names $fields = array_keys($array[0]); $fields = "`".implode("`,`", $fields)."`";
| // Field names $fields = array_keys($array[0]); $fields = "`".implode("`,`", $fields)."`";
|
Zeile 792 | Zeile 805 |
---|
$comma = ', '; }
|
$comma = ', '; }
|
if(!empty($where)) { $query .= " WHERE $where"; } if(!empty($limit)) { $query .= " LIMIT $limit"; } return $this->write_query("
| if(!empty($where)) { $query .= " WHERE $where"; } if(!empty($limit)) { $query .= " LIMIT $limit"; } return $this->write_query("
|
UPDATE {$this->table_prefix}$table SET $query
|
UPDATE {$this->table_prefix}$table SET $query
|
"); }
/**
| "); }
/**
|
* Build a delete query. * * @param string The table name to perform the query on.
| * Build a delete query. * * @param string The table name to perform the query on.
|
Zeile 820 | Zeile 833 |
---|
{ $query = ""; if(!empty($where))
|
{ $query = ""; if(!empty($where))
|
{
| {
|
$query .= " WHERE $where"; }
| $query .= " WHERE $where"; }
|
Zeile 845 | Zeile 858 |
---|
*/ function escape_string($string) {
|
*/ function escape_string($string) {
|
| if($this->db_encoding == 'utf8') { $string = validate_utf8_string($string, false); } elseif($this->db_encoding == 'utf8mb4') { $string = validate_utf8_string($string); }
|
if(function_exists("mysql_real_escape_string") && $this->read_link) { $string = mysql_real_escape_string($string, $this->read_link);
| if(function_exists("mysql_real_escape_string") && $this->read_link) { $string = mysql_real_escape_string($string, $this->read_link);
|
Zeile 996 | Zeile 1018 |
---|
{ $table_type = my_strtoupper($status['Type']); }
|
{ $table_type = my_strtoupper($status['Type']); }
|
if($version >= '3.23.23' && $table_type == 'MYISAM')
| if(version_compare($version, '3.23.23', '>=') && ($table_type == 'MYISAM' || $table_type == 'ARIA')) { return true; } elseif(version_compare($version, '5.6', '>=') && $table_type == 'INNODB')
|
{ return true; }
| { return true; }
|
Zeile 1040 | Zeile 1066 |
---|
{ $version = $this->get_version(); $supports_fulltext = $this->supports_fulltext($table);
|
{ $version = $this->get_version(); $supports_fulltext = $this->supports_fulltext($table);
|
if($version >= '4.0.1' && $supports_fulltext == true)
| if(version_compare($version, '4.0.1', '>=') && $supports_fulltext == true)
|
{ return true; }
| { return true; }
|
Zeile 1244 | Zeile 1270 |
---|
'latin5' => 'ISO 8859-9 Turkish', 'armscii8' => 'ARMSCII-8 Armenian', 'utf8' => 'UTF-8 Unicode',
|
'latin5' => 'ISO 8859-9 Turkish', 'armscii8' => 'ARMSCII-8 Armenian', 'utf8' => 'UTF-8 Unicode',
|
| 'utf8mb4' => '4-Byte UTF-8 Unicode (requires MySQL 5.5.3 or above)',
|
'ucs2' => 'UCS-2 Unicode', 'cp866' => 'DOS Russian', 'keybcs2' => 'DOS Kamenicky Czech-Slovak',
| 'ucs2' => 'UCS-2 Unicode', 'cp866' => 'DOS Russian', 'keybcs2' => 'DOS Kamenicky Czech-Slovak',
|
Zeile 1292 | Zeile 1319 |
---|
'latin5' => 'latin5_turkish_ci', 'armscii8' => 'armscii8_general_ci', 'utf8' => 'utf8_general_ci',
|
'latin5' => 'latin5_turkish_ci', 'armscii8' => 'armscii8_general_ci', 'utf8' => 'utf8_general_ci',
|
| 'utf8mb4' => 'utf8mb4_general_ci',
|
'ucs2' => 'ucs2_general_ci', 'cp866' => 'cp866_general_ci', 'keybcs2' => 'keybcs2_general_ci',
| 'ucs2' => 'ucs2_general_ci', 'cp866' => 'cp866_general_ci', 'keybcs2' => 'keybcs2_general_ci',
|