Version 3.1.4
This commit is contained in:
1 parent
1d4720f3e2
commit
ae5c01cc78
2563 files changed
+283048
-240689
No files matched your search
@@ -1,18 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* IP.Board v3.1.4
|
||||
* MySQL Database Driver :: MySQL client
|
||||
* Last Updated: $Date: 2009-09-15 08:34:24 -0400 (Tue, 15 Sep 2009) $
|
||||
* Last Updated: $Date: 2010-07-13 19:56:26 -0400 (Tue, 13 Jul 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: matt $
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Services Kernel
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @package IP.Board
|
||||
* @subpackage Kernel
|
||||
* @link http://www.invisionpower.com
|
||||
* @since Monday 28th February 2005 16:46
|
||||
* @version $Revision: 327 $
|
||||
* @version $Revision: 438 $
|
||||
*/
|
||||
|
||||
class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
@@ -29,11 +32,11 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
{
|
||||
define( 'MYSQLI_USED', 1 );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// Set up any required connect vars here
|
||||
//--------------------------------------
|
||||
|
||||
|
||||
$this->connect_vars['mysql_tbl_type'] = "";
|
||||
}
|
||||
|
||||
@@ -48,20 +51,20 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
//-----------------------------------------
|
||||
// Done SQL prefix yet?
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
$this->_setPrefix();
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Load query file
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
$this->_loadCacheFile();
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Connect
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->obj['persistent'] AND ! IPS_MAIN_DB_CLASS_LEGACY )
|
||||
|
||||
if ( $this->obj['persistent'] )
|
||||
{
|
||||
$this->connection_id = @mysql_pconnect( $this->obj['sql_host'] ,
|
||||
$this->obj['sql_user'] ,
|
||||
@@ -70,22 +73,12 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( IPS_MAIN_DB_CLASS_LEGACY )
|
||||
{
|
||||
$this->connection_id = @mysql_connect( $this->obj['sql_host'] ,
|
||||
$this->obj['sql_user'] ,
|
||||
$this->obj['sql_pass']
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->connection_id = @mysql_connect( $this->obj['sql_host'] ,
|
||||
$this->obj['sql_user'] ,
|
||||
$this->obj['sql_pass'] ,
|
||||
$this->obj['force_new_connection']
|
||||
);
|
||||
}
|
||||
{
|
||||
$this->connection_id = @mysql_connect( $this->obj['sql_host'] ,
|
||||
$this->obj['sql_user'] ,
|
||||
$this->obj['sql_pass'] ,
|
||||
$this->obj['force_new_connection']
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $this->connection_id )
|
||||
@@ -155,12 +148,12 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
//-----------------------------------------
|
||||
// Change the table prefix if needed
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if ( $this->no_prefix_convert )
|
||||
{
|
||||
$bypass = 1;
|
||||
}
|
||||
|
||||
|
||||
if ( ! $bypass )
|
||||
{
|
||||
if ( $this->obj['sql_tbl_prefix'] != "ibf_" and ! $this->prefix_changed )
|
||||
@@ -210,11 +203,11 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Run the query
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
#I had to switch this around... The query goes first, connection id second. Otherwise it just breaks - KF
|
||||
#$this->query_id = mysql_query($this->connection_id, $the_query );
|
||||
$this->query_id = mysql_query( $the_query, $this->connection_id );
|
||||
@@ -222,7 +215,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
//-----------------------------------------
|
||||
// Reset array...
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
$this->force_data_type = array();
|
||||
$this->allow_sub_select = false;
|
||||
|
||||
@@ -230,25 +223,25 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
{
|
||||
$this->throwFatalError("mySQL query error: $the_query");
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Debug?
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if ( ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] ) OR ( $this->obj['use_bad_log'] AND $this->obj['bad_log'] ) OR ( $this->obj['use_slow_log'] AND $this->obj['slow_log'] ) )
|
||||
{
|
||||
$endtime = IPSDebug::endTimer();
|
||||
$_data = '';
|
||||
|
||||
|
||||
if ( preg_match( "/^(?:\()?select/i", $the_query ) )
|
||||
{
|
||||
$eid = mysql_query("EXPLAIN {$the_query}", $this->connection_id);
|
||||
$_bad = false;
|
||||
|
||||
|
||||
while( $array = mysql_fetch_array($eid) )
|
||||
{
|
||||
$array['extra'] = isset( $array['extra'] ) ? $array['extra'] : '';
|
||||
|
||||
|
||||
$_data .= "\n+------------------------------------------------------------------------------+";
|
||||
$_data .= "\n|Table: ". $array['table'];
|
||||
$_data .= "\n|Type: ". $array['type'];
|
||||
@@ -259,18 +252,18 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
$_data .= "\n|Rows: ". $array['rows'];
|
||||
$_data .= "\n|Extra: ". $array['Extra'];
|
||||
//$_data .= "\n+------------------------------------------------------------------------------+";
|
||||
|
||||
|
||||
if ( ( $this->obj['use_bad_log'] AND $this->obj['bad_log'] ) AND stristr( $array['Extra'], 'filesort' ) OR stristr( $array['Extra'], 'temporary' ) )
|
||||
{
|
||||
$this->writeDebugLog( $the_query, $_data, $endtime, $this->obj['bad_log'], TRUE );
|
||||
}
|
||||
|
||||
|
||||
if ( ( $this->obj['use_slow_log'] AND $this->obj['slow_log'] ) AND $endtime >= $this->obj['use_slow_log'] )
|
||||
{
|
||||
$this->writeDebugLog( $the_query, $_data, $endtime, $this->obj['slow_log'], TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] )
|
||||
{
|
||||
$this->writeDebugLog( $the_query, $_data, $endtime );
|
||||
@@ -284,21 +277,21 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Debugging?
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if ($this->obj['debug'])
|
||||
{
|
||||
$endtime = IPSDebug::endTimer();
|
||||
|
||||
|
||||
$shutdown = $this->is_shutdown ? 'SHUTDOWN QUERY: ' : '';
|
||||
|
||||
|
||||
if ( preg_match( "/^(?:\()?select/i", $the_query ) )
|
||||
{
|
||||
$eid = mysql_query( "EXPLAIN {$the_query}", $this->connection_id );
|
||||
|
||||
|
||||
$this->debug_html .= "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FFE8F3' align='center'>
|
||||
<tr>
|
||||
<td colspan='8' style='font-size:14px' bgcolor='#FFC5Cb'><b>{$shutdown}Select Query</b></td>
|
||||
@@ -314,7 +307,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
while( $array = mysql_fetch_array($eid) )
|
||||
{
|
||||
$type_col = '#FFFFFF';
|
||||
|
||||
|
||||
if ($array['type'] == 'ref' or $array['type'] == 'eq_ref' or $array['type'] == 'const')
|
||||
{
|
||||
$type_col = '#D8FFD4';
|
||||
@@ -323,7 +316,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
{
|
||||
$type_col = '#FFEEBA';
|
||||
}
|
||||
|
||||
|
||||
$this->debug_html .= "<tr bgcolor='#FFFFFF'>
|
||||
<td>$array[table] </td>
|
||||
<td bgcolor='$type_col'>$array[type] </td>
|
||||
@@ -335,14 +328,14 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
<td>$array[Extra] </td>
|
||||
</tr>\n";
|
||||
}
|
||||
|
||||
|
||||
$this->sql_time += $endtime;
|
||||
|
||||
|
||||
if ($endtime > 0.1)
|
||||
{
|
||||
$endtime = "<span style='color:red'><b>$endtime</b></span>";
|
||||
}
|
||||
|
||||
|
||||
$this->debug_html .= "<tr>
|
||||
<td colspan='8' bgcolor='#FFD6DC' style='font-size:14px'><b>MySQL time</b>: $endtime</b></td>
|
||||
</tr>
|
||||
@@ -363,11 +356,11 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
</table><br />\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->query_count++;
|
||||
|
||||
|
||||
$this->obj['cached_queries'][] = $the_query;
|
||||
|
||||
|
||||
return $this->query_id;
|
||||
}
|
||||
|
||||
@@ -381,7 +374,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
{
|
||||
return mysql_affected_rows( $this->connection_id );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve number of rows in result set
|
||||
*
|
||||
@@ -398,7 +391,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
|
||||
return mysql_num_rows( $query_id );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve latest autoincrement insert id
|
||||
*
|
||||
@@ -409,7 +402,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
{
|
||||
return mysql_insert_id($this->connection_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the current thread id
|
||||
*
|
||||
@@ -420,7 +413,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
{
|
||||
return mysql_thread_id($this->connection_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Free result set from memory
|
||||
*
|
||||
@@ -434,10 +427,10 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
{
|
||||
$query_id = $this->query_id;
|
||||
}
|
||||
|
||||
|
||||
@mysql_free_result( $query_id );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve row from database
|
||||
*
|
||||
@@ -451,9 +444,9 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
{
|
||||
$query_id = $this->query_id;
|
||||
}
|
||||
|
||||
|
||||
$this->record_row = mysql_fetch_array( $query_id, MYSQL_ASSOC );
|
||||
|
||||
|
||||
return $this->record_row;
|
||||
}
|
||||
|
||||
@@ -467,12 +460,12 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
public function fetchCalculatedRows( $alias='count' )
|
||||
{
|
||||
$calcRowsHandle = mysql_query( "SELECT FOUND_ROWS() as " . $alias, $this->connection_id );
|
||||
|
||||
|
||||
$val = mysql_fetch_array( $calcRowsHandle, MYSQL_ASSOC );
|
||||
|
||||
|
||||
return intval( $val[ $alias ] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get array of fields in result set
|
||||
*
|
||||
@@ -483,17 +476,17 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
public function getResultFields( $query_id=null )
|
||||
{
|
||||
$fields = array();
|
||||
|
||||
|
||||
if ( !$query_id )
|
||||
{
|
||||
$query_id = $this->query_id;
|
||||
}
|
||||
|
||||
|
||||
while( $field = mysql_fetch_field($query_id) )
|
||||
{
|
||||
$fields[] = $field;
|
||||
}
|
||||
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
@@ -509,14 +502,14 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
{
|
||||
return $this->cached_tables;
|
||||
}
|
||||
|
||||
|
||||
$current = $this->return_die;
|
||||
$this->return_die = true;
|
||||
|
||||
|
||||
$qid = $this->query( "SHOW TABLES FROM `{$this->obj['sql_database']}`" );
|
||||
|
||||
|
||||
$this->return_die = $current;
|
||||
|
||||
|
||||
if( $qid AND $this->getTotalRows($qid) )
|
||||
{
|
||||
while( $result = mysql_fetch_array($qid) )
|
||||
@@ -524,12 +517,12 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
$this->cached_tables[] = $result[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mysql_free_result($qid);
|
||||
|
||||
|
||||
return $this->cached_tables;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve SQL server version
|
||||
*
|
||||
@@ -541,19 +534,19 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
if ( ! $this->sql_version and ! $this->true_version )
|
||||
{
|
||||
$this->query( "SELECT VERSION() AS version" );
|
||||
|
||||
|
||||
if ( ! $row = $this->fetch() )
|
||||
{
|
||||
$this->query( "SHOW VARIABLES LIKE 'version' ");
|
||||
$row = $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
$this->true_version = $row['version'];
|
||||
$tmp = explode( '.', preg_replace( "#[^\d\.]#", "\\1", $row['version'] ) );
|
||||
|
||||
|
||||
$this->sql_version = sprintf('%d%02d%02d', $tmp[0], $tmp[1], $tmp[2] );
|
||||
}
|
||||
|
||||
|
||||
return $this->sql_version;
|
||||
}
|
||||
|
||||
@@ -566,7 +559,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
*/
|
||||
public function addSlashes( $t )
|
||||
{
|
||||
return ( IPS_MAIN_DB_CLASS_LEGACY ) ? mysql_escape_string($t) : mysql_real_escape_string($t, $this->connection_id );
|
||||
return @mysql_real_escape_string( $t, $this->connection_id );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -586,7 +579,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
return @mysql_errno();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get SQL error message
|
||||
*
|
||||
@@ -604,6 +597,6 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
|
||||
return @mysql_error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // end class
|
||||
Reference in new issue
Block a user