mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-27 22:33:10 +09:00
parent
0c6bc8fbb1
commit
03e5909036
6 changed files with 81 additions and 4 deletions
|
|
@ -11,4 +11,5 @@ class IndexHint
|
|||
public $hint_type = '';
|
||||
public $index_name = '';
|
||||
public $table_name = '';
|
||||
public $var;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -469,7 +469,14 @@ class Query extends VariableBase
|
|||
{
|
||||
$key = $index_hint->hint_type ?: 'USE';
|
||||
$index_list[$key] = $index_list[$key] ?? [];
|
||||
$index_list[$key][] = $index_hint->index_name;
|
||||
if ($index_hint->var && isset($this->_args[$index_hint->var]))
|
||||
{
|
||||
$index_list[$key][] = self::quoteName($this->_args[$index_hint->var]);
|
||||
}
|
||||
elseif ($index_hint->index_name)
|
||||
{
|
||||
$index_list[$key][] = self::quoteName($index_hint->index_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -477,7 +484,10 @@ class Query extends VariableBase
|
|||
$result = [];
|
||||
foreach ($index_list as $key => $val)
|
||||
{
|
||||
$result[] = sprintf('%s INDEX (%s)', $key, implode(', ', $val));
|
||||
if (count($val))
|
||||
{
|
||||
$result[] = sprintf('%s INDEX (%s)', $key, implode(', ', $val));
|
||||
}
|
||||
}
|
||||
return implode(' ', $result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,15 @@ class DBQueryParser extends BaseParser
|
|||
$index_hint->hint_type = strtoupper(trim($tag['type'])) ?: 'USE';
|
||||
$index_hint->index_name = trim($tag['name']) ?: '';
|
||||
$index_hint->table_name = trim($tag['table']) ?: '';
|
||||
if ($index_hint->index_name)
|
||||
if (isset($tag['var']) && trim($tag['var']))
|
||||
{
|
||||
$index_hint->var = trim($tag['var']);
|
||||
}
|
||||
if (isset($tag['default']) && trim($tag['default']))
|
||||
{
|
||||
$index_hint->index_name = trim($tag['default']);
|
||||
}
|
||||
if ($index_hint->index_name || $index_hint->var)
|
||||
{
|
||||
$query->index_hints[] = $index_hint;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue