Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -3,19 +3,19 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* MySQL Database Driver :: Further loads mysql or mysqli client appropriately
|
||||
* Last Updated: $Date: 2010-10-06 12:04:54 -0400 (Wed, 06 Oct 2010) $
|
||||
* Last Updated: $Date: 2011-10-10 16:21:29 -0400 (Mon, 10 Oct 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: mmecham $
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @subpackage Kernel
|
||||
* @link http://www.invisionpower.com
|
||||
* @link http://hatynka.in
|
||||
* @since Monday 28th February 2005 16:46
|
||||
* @version $Revision: 473 $
|
||||
* @version $Revision: 9590 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ define( 'REPLACE_TYPE', 2 );
|
||||
*/
|
||||
if ( ! class_exists( 'dbMain' ) )
|
||||
{
|
||||
require_once( dirname( __FILE__ ) . '/classDb.php' );
|
||||
require_once( dirname( __FILE__ ) . '/classDb.php' );/*noLibHook*/
|
||||
}
|
||||
|
||||
abstract class db_main_mysql extends dbMain
|
||||
@@ -59,6 +59,16 @@ abstract class db_main_mysql extends dbMain
|
||||
*/
|
||||
public $fieldNameEncapsulate = '`';
|
||||
|
||||
/**
|
||||
* Return the connection ID
|
||||
*
|
||||
* @return resource Connection ID
|
||||
*/
|
||||
public function getConnectionId()
|
||||
{
|
||||
return $this->connection_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete data from a table
|
||||
*
|
||||
@@ -109,7 +119,7 @@ abstract class db_main_mysql extends dbMain
|
||||
* @param boolean [Optional] $set is already pre-formatted
|
||||
* @return resource Query id
|
||||
*/
|
||||
public function update( $table, $set, $where='', $shutdown=false, $preformatted=false )
|
||||
public function update( $table, $set, $where='', $shutdown=false, $preformatted=false, $debug=false )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Form query
|
||||
@@ -123,7 +133,7 @@ abstract class db_main_mysql extends dbMain
|
||||
{
|
||||
$query .= " WHERE " . $where;
|
||||
}
|
||||
|
||||
|
||||
return $this->_determineShutdownAndRun( $query, $shutdown );
|
||||
}
|
||||
|
||||
@@ -472,11 +482,18 @@ abstract class db_main_mysql extends dbMain
|
||||
* @access public
|
||||
* @param string Table name
|
||||
* @param string Field name
|
||||
* @return resource Query id
|
||||
* @return mixed Query id resource, or null
|
||||
*/
|
||||
public function addFulltextIndex( $table, $field )
|
||||
{
|
||||
return $this->query( "ALTER TABLE " . $this->obj['sql_tbl_prefix'] . $table . " ADD FULLTEXT({$field})" );
|
||||
if( $this->checkFulltextSupport() )
|
||||
{
|
||||
return $this->query( "ALTER TABLE " . $this->obj['sql_tbl_prefix'] . $table . " ADD FULLTEXT({$field})" );
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -567,24 +584,12 @@ abstract class db_main_mysql extends dbMain
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Un-escape strings escaped for DB
|
||||
*
|
||||
* @access public
|
||||
* @param string Text to un-escape
|
||||
* @return string Un-escaped text
|
||||
*/
|
||||
public function removeSlashes( $t )
|
||||
{
|
||||
return $t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build order by clause
|
||||
*
|
||||
* @access protected
|
||||
* @param string Order by clause
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _buildOrderBy( $order )
|
||||
{
|
||||
@@ -599,7 +604,7 @@ abstract class db_main_mysql extends dbMain
|
||||
*
|
||||
* @access protected
|
||||
* @param string Having clause
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _buildHaving( $having_clause )
|
||||
{
|
||||
@@ -614,7 +619,7 @@ abstract class db_main_mysql extends dbMain
|
||||
*
|
||||
* @access protected
|
||||
* @param string Group by clause
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _buildGroupBy( $group )
|
||||
{
|
||||
@@ -630,7 +635,7 @@ abstract class db_main_mysql extends dbMain
|
||||
* @access protected
|
||||
* @param integer Start offset
|
||||
* @param integer [Optional] Number of records
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _buildLimit( $offset, $limit=0 )
|
||||
{
|
||||
@@ -733,16 +738,26 @@ abstract class db_main_mysql extends dbMain
|
||||
* @param array Array of values to allow
|
||||
* @return string SQL-formatted concat string
|
||||
*/
|
||||
public function buildLikeChain( $column, $data )
|
||||
public function buildLikeChain( $column, $data, $isNumerical=true )
|
||||
{
|
||||
$return = $column . "='*'";
|
||||
|
||||
if ( is_array( $data ) )
|
||||
$comma = ',';
|
||||
|
||||
if ( ! is_array( $data ) )
|
||||
{
|
||||
foreach( $data as $id )
|
||||
{
|
||||
$return .= " OR " . $column . " LIKE '%," . $id . ",%'";
|
||||
}
|
||||
return '1=1';
|
||||
}
|
||||
|
||||
if ( ! $isNumerical )
|
||||
{
|
||||
$comma = '';
|
||||
$first = array_shift( $data );
|
||||
$return = $column . ' LIKE \'%' . $first . '%\'';
|
||||
}
|
||||
|
||||
foreach( $data as $id )
|
||||
{
|
||||
$return .= " OR " . $column . " LIKE '%" . $comma . $id . $comma . "%'";
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -765,6 +780,11 @@ abstract class db_main_mysql extends dbMain
|
||||
|
||||
foreach( $ids as $i )
|
||||
{
|
||||
if ( ! $i )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$_or[] = "FIND_IN_SET(" . $i . "," . $field . ")";
|
||||
}
|
||||
|
||||
@@ -785,6 +805,20 @@ abstract class db_main_mysql extends dbMain
|
||||
return $where . ' )';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Timezone
|
||||
*
|
||||
* @param float UTC Offset (e.g. 6 or -4.5)
|
||||
*/
|
||||
public function setTimeZone( $offset )
|
||||
{
|
||||
$offset = number_format( floatval( $offset ), 2 );
|
||||
$decimal = substr( $offset, strpos( $offset, '.' ) + 1 );
|
||||
$offset = ( $offset >= 0 ? '+' . floor( $offset ) : ceil( $offset ) ) . ':' . str_pad( $decimal = ( 60 / 100 ) * $decimal, 2, '0' );
|
||||
|
||||
$this->query( "SET time_zone = '{$offset}';" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build instr string
|
||||
*
|
||||
@@ -906,6 +940,22 @@ abstract class db_main_mysql extends dbMain
|
||||
{
|
||||
return $is_null ? " IS NULL " : " IS NOT NULL ";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build coalesce statement
|
||||
*
|
||||
* @param array Values to check
|
||||
* @return string SQL-formatted coalesce statement
|
||||
*/
|
||||
public function buildCoalesce( $values=array() )
|
||||
{
|
||||
if( !count($values) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return "COALESCE(" . implode( ',', $values ) . ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build from_unixtime string
|
||||
@@ -927,6 +977,17 @@ abstract class db_main_mysql extends dbMain
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build unix_timestamp string
|
||||
*
|
||||
* @param string Column name
|
||||
* @return string SQL-formatted unix_timestamp string
|
||||
*/
|
||||
public function buildUnixTimestamp( $column )
|
||||
{
|
||||
return "UNIX_TIMESTAMP(" . $column . ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build date_format string
|
||||
*
|
||||
@@ -963,7 +1024,7 @@ abstract class db_main_mysql extends dbMain
|
||||
*/
|
||||
public function buildSearchStatement( $column, $keyword, $booleanMode=true, $returnRanking=false, $useFulltext=true )
|
||||
{
|
||||
if( !$useFulltext )
|
||||
if( !$useFulltext OR strtolower($this->connect_vars['mysql_tbl_type']) != 'myisam' )
|
||||
{
|
||||
return "{$column} LIKE '%{$keyword}%'";
|
||||
}
|
||||
@@ -972,14 +1033,25 @@ abstract class db_main_mysql extends dbMain
|
||||
return "MATCH( {$column} ) AGAINST( '{$keyword}' " . ( $booleanMode === TRUE ? 'IN BOOLEAN MODE' : '' ) . " )" . ( $returnRanking === TRUE ? ' as ranking' : '' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds a call to MD5 equivalent
|
||||
*
|
||||
* @access public
|
||||
* @return string SQL-formatted MD5 function call string
|
||||
*/
|
||||
public function buildMd5Statement( $statement )
|
||||
{
|
||||
return "MD5(" . $statement . ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build calc rows
|
||||
* We don't have to do anything for MySQL 4+ as it's handled internally
|
||||
* This is always called before the limit is applied
|
||||
*
|
||||
* @access public
|
||||
* @return void Sets $this->_calcRows
|
||||
* @return @e void Sets $this->_calcRows
|
||||
*/
|
||||
protected function _buildCalcRows()
|
||||
{
|
||||
@@ -1005,7 +1077,7 @@ abstract class db_main_mysql extends dbMain
|
||||
* @param string Table name
|
||||
* @param string [Optional] Where clause
|
||||
* @param array [Optional] Joined table data
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _buildSelect( $get, $table, $where, $add_join=array(), $calcRows=FALSE )
|
||||
{
|
||||
@@ -1068,12 +1140,12 @@ abstract class db_main_mysql extends dbMain
|
||||
foreach( $add_join as $join )
|
||||
{
|
||||
# Push join's select to stack
|
||||
if ( isset($join['select']) AND $join['select'] )
|
||||
if ( !empty($join['select']) )
|
||||
{
|
||||
$select_array[] = $join['select'];
|
||||
}
|
||||
|
||||
if ( !isset($join['type']) OR !$join['type'] OR $join['type'] == 'left' )
|
||||
if ( empty($join['type']) OR $join['type'] == 'left' )
|
||||
{
|
||||
$hasLeft = true;
|
||||
# Join is left or not specified (assume left)
|
||||
@@ -1149,11 +1221,11 @@ abstract class db_main_mysql extends dbMain
|
||||
|
||||
if ( extension_loaded('mysqli') AND ! defined( 'FORCE_MYSQL_ONLY' ) )
|
||||
{
|
||||
require( dirname( __FILE__ ) . "/classDbMysqliClient.php" );
|
||||
require( dirname( __FILE__ ) . "/classDbMysqliClient.php" );/*noLibHook*/
|
||||
}
|
||||
else
|
||||
{
|
||||
require( dirname( __FILE__ ) . "/classDbMysqlClient.php" );
|
||||
require( dirname( __FILE__ ) . "/classDbMysqlClient.php" );/*noLibHook*/
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
Reference in new issue
Block a user