* Support for specifying USE INDEX for any of >1 tables
This commit is contained in:
parent
f3c2a19daf
commit
32fc405ea7
1 changed files with 20 additions and 2 deletions
|
|
@ -718,7 +718,7 @@ class Database {
|
|||
$tailOpts .= ' LOCK IN SHARE MODE';
|
||||
}
|
||||
|
||||
if ( isset( $options['USE INDEX'] ) ) {
|
||||
if ( isset( $options['USE INDEX'] ) && ! is_array( $options['USE INDEX'] ) ) {
|
||||
$useIndex = $this->useIndexClause( $options['USE INDEX'] );
|
||||
} else {
|
||||
$useIndex = '';
|
||||
|
|
@ -738,7 +738,10 @@ class Database {
|
|||
$options = array( $options );
|
||||
}
|
||||
if( is_array( $table ) ) {
|
||||
$from = ' FROM ' . implode( ',', array_map( array( &$this, 'tableName' ), $table ) );
|
||||
if ( @is_array( $options['USE INDEX'] ) )
|
||||
$from = ' FROM ' . $this->tableNamesWithUseIndex( $table, $options['USE INDEX'] );
|
||||
else
|
||||
$from = ' FROM ' . implode( ',', array_map( array( &$this, 'tableName' ), $table ) );
|
||||
} elseif ($table!='') {
|
||||
$from = ' FROM ' . $this->tableName( $table );
|
||||
} else {
|
||||
|
|
@ -1130,6 +1133,21 @@ class Database {
|
|||
return $retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
function tableNamesWithUseIndex( $tables, $use_index ) {
|
||||
$ret = array();
|
||||
|
||||
foreach ( $tables as $table )
|
||||
if ( @$use_index[$table] !== null )
|
||||
$ret[] = $this->tableName( $table ) . ' ' . $this->useIndexClause( implode( ',', (array)$use_index[$table] ) );
|
||||
else
|
||||
$ret[] = $this->tableName( $table );
|
||||
|
||||
return implode( ',', $ret );
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for addslashes()
|
||||
* @param string $s String to be slashed.
|
||||
|
|
|
|||
Loading…
Reference in a new issue