$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 = '';
$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 {
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.