Added support for index hinting.
This commit is contained in:
parent
c32ee1a12e
commit
7e1a45e9cb
1 changed files with 35 additions and 0 deletions
|
@ -110,6 +110,14 @@ class Model extends Object
|
|||
*/
|
||||
protected $joins = false; // JOIN
|
||||
|
||||
/**
|
||||
* [Index] Hints
|
||||
*
|
||||
* @access protected
|
||||
* @var mixed
|
||||
*/
|
||||
protected $hints = false; // USE INDEX
|
||||
|
||||
/**
|
||||
* Conditions
|
||||
*
|
||||
|
@ -414,6 +422,33 @@ class Model extends Object
|
|||
}
|
||||
}
|
||||
|
||||
// Adds the index hints
|
||||
if ($this->hints != false)
|
||||
{
|
||||
if (is_array($this->hints))
|
||||
{
|
||||
foreach ($this->hints as $hint => $columns)
|
||||
{
|
||||
if (is_array($columns))
|
||||
{
|
||||
$this->sql[] = $hint . ' (' . implode(', ', $columns) . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$format = (stripos($columns, 'USE ') === false);
|
||||
|
||||
$this->sql[] = ($format == true ? 'USE INDEX (' : '') . $columns . ($format == true ? ')' : '');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$format = (stripos($this->hints, 'USE ') === false);
|
||||
|
||||
$this->sql[] = ($format == true ? 'USE INDEX (' : '') . $this->hints . ($format == true ? ')' : '');
|
||||
}
|
||||
}
|
||||
|
||||
// Adds the WHERE conditionals
|
||||
if ($this->conditions != false)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue