Added index hints for SQL Server. Improvements to existing query hints for Mysql and Cubrid.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9481 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-10-04 13:19:45 +00:00
parent eaa1a02adc
commit 3815aece09
19 changed files with 320 additions and 6 deletions

View file

@ -12,9 +12,19 @@
function getIndexHintString(){
$result = '';
// Retrieve table prefix, to add it to index name
$db_info = Context::getDBInfo();
$prefix = $db_info->master_db["db_table_prefix"];
foreach($this->index_hints_list as $index_hint){
$result .= $this->alias . '.' . $index_hint->getIndexName()
. ($index_hint->getIndexHintType() == 'FORCE' ? '(+)' : '') . ', ';
$index_hint_type = $index_hint->getIndexHintType();
if($index_hint_type !== 'IGNORE'){
$result .= $this->alias . '.'
. '"' . $prefix . substr($index_hint->getIndexName(), 1)
. ($index_hint_type == 'FORCE' ? '(+)' : '')
. ', ';
}
}
$result = substr($result, 0, -2);

View file

@ -0,0 +1,29 @@
<?php
class MssqlTableWithHint extends Table {
var $name;
var $alias;
var $index_hints_list;
function MssqlTableWithHint($name, $alias = NULL, $index_hints_list){
parent::Table($name, $alias);
$this->index_hints_list = $index_hints_list;
}
function toString(){
$result = parent::toString();
$index_hint_string = '';
foreach($this->index_hints_list as $index_hint){
$index_hint_type = $index_hint->getIndexHintType();
if(in_array($index_hint_type, array('USE', 'FORCE')))
$index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
}
if($index_hint_string != ''){
$result .= ' WITH(' . substr($index_hint_string, 0, -2) . ') ';
}
return $result;
}
}
?>