Version 3.4.5

This commit is contained in:
Neo committed 2025-12-19 00:38:12 -08:00
1 parent fb6b5baabc
commit e4478369d8
1360 files changed
+228921 -179445

No files matched your search

+142 -15
View File
@@ -3,26 +3,29 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* IP.Board v3.4.5
* MySQL Database Driver :: Further loads mysql or mysqli client appropriately
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* Last Updated: $Date: 2012-09-17 11:58:03 -0400 (Mon, 17 Sep 2012) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: mark $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Monday 28th February 2005 16:46
* @version $Revision: 10914 $
* @version $Revision: 11341 $
*/
/**
* 1 = Replace into
* 2 = Insert into...on duplicate key update
*/
define( 'REPLACE_TYPE', 2 );
if( !defined('REPLACE_TYPE') )
{
define( 'REPLACE_TYPE', 2 );
}
/**
* Handle base class definitions
@@ -112,23 +115,141 @@ abstract class db_main_mysql extends dbMain
* @param string [Optional] Where clause
* @param boolean [Optional] Run on shutdown
* @param boolean [Optional] $set is already pre-formatted
* @param array [Optional] Joined table data
* @return @e resource
*/
public function update( $table, $set, $where='', $shutdown=false, $preformatted=false, $debug=false )
public function update( $table, $set, $where='', $shutdown=false, $preformatted=false, $add_join=array() )
{
//-----------------------------------------
// Form query
// Normal
//-----------------------------------------
if ( empty( $add_join ) )
{
/* Compile the update clause */
$dba = $preformatted ? $set : $this->compileUpdateString( $set );
/* Put it together */
$query = "UPDATE " . $this->obj['sql_tbl_prefix'] . $table . " SET " . $dba;
/* Add in a where clause if necessary (we don't want to something silly like delete all the tickets...) */
if ( $where )
{
$query .= " WHERE " . $where;
}
}
//-----------------------------------------
// With joins
//-----------------------------------------
else
{
//-----------------------------------------
// OK, here we go...
//-----------------------------------------
$dba = $preformatted ? $set : $this->compileUpdateString( $set );
$from_array = array();
$joinleft_array = array();
$where_array = array();
$final_from = array();
$from_array[] = $table;
$hasLeft = false;
$hasInner = false;
$query = "UPDATE " . $this->obj['sql_tbl_prefix'] . $table . " SET " . $dba;
if ( $where )
{
$where_array[] = $where;
}
if ( $where )
{
$query .= " WHERE " . $where;
}
//-----------------------------------------
// Loop through JOINs and sort info
//-----------------------------------------
if ( is_array( $add_join ) and count( $add_join ) )
{
foreach( $add_join as $join )
{
if ( ! is_array( $join ) )
{
continue;
}
if ( empty($join['type']) OR $join['type'] == 'left' )
{
$hasLeft = true;
# Join is left or not specified (assume left)
$tmp = " LEFT JOIN ";
foreach( $join['from'] as $tbl => $alias )
{
$tmp .= $this->obj['sql_tbl_prefix'].$tbl.' '.$alias;
}
if ( $join['where'] )
{
$tmp .= " ON ( ".$join['where']." ) ";
}
$joinleft_array[] = $tmp;
unset( $tmp );
}
else if ( $join['type'] == 'inner' )
{
$hasInner = true;
# Join is inline
$from_array[] = $join['from'];
if ( $join['where'] )
{
$where_array[] = $join['where'];
}
}
else
{
# Not using any other type of join
}
}
}
//-----------------------------------------
// Build it..
//-----------------------------------------
foreach( $from_array as $i )
{
foreach( $i as $tbl => $alias )
{
$final_from[] = $this->obj['sql_tbl_prefix'] . $tbl . ' ' . $alias;
}
}
#http://bugs.mysql.com/bug.php?id=37925
$table = ( $hasLeft === true && $hasInner === true ) ? '(' . implode( ",", $final_from ) . ')' : implode( ",", $final_from );
$where = implode( " AND " , $where_array );
$join = implode( "\n" , $joinleft_array );
$query = "UPDATE {$table}";
if ( $join )
{
$query .= " " . $join . " ";
}
$query .= "SET " . ( $preformatted ? $set : $this->compileUpdateString( $set ) );
if ( $where != "" )
{
$query .= " WHERE " . $where;
}
}
//-----------------------------------------
// Run
//-----------------------------------------
return $this->_determineShutdownAndRun( $query, $shutdown );
}
@@ -1021,11 +1142,17 @@ abstract class db_main_mysql extends dbMain
* @param string [Optional] Where clause
* @param array [Optional] Joined table data
* @param boolean Calculate total rows too
* @param array [Optional] Force index
* @return @e void
*/
protected function _buildSelect( $get, $table, $where, $add_join=array(), $calcRows=FALSE )
protected function _buildSelect( $get, $table, $where, $add_join=array(), $calcRows=FALSE, $forceIndex=array() )
{
$_calcRows = ( $calcRows === TRUE ) ? 'SQL_CALC_FOUND_ROWS ' : '';
if ( !empty( $forceIndex ) )
{
$table .= ' FORCE INDEX('. implode( ',', array_map( create_function( '$v', 'return $v == \'PRIMARY\' ? $v : "'.$this->fieldNameEncapsulate.'{$v}'.$this->fieldNameEncapsulate.'";' ), $forceIndex ) ) .')';
}
if( !count($add_join) )
{