[eluser]tonanbarbarian[/eluser]
I have found 3 issues with the ODBC driver in 1.6
1. It is the only driver with a constructor. This breaks the class so that it does not return a query object correctly.
The only thing that the constructor is doing is setting a default value for the _random_keyword
I found it easiest to remove the constructor and place the assignment of the value to the _random_keyword in to the db_select - since it didnt have anything else to do anyway
Code:
// function CI_DB_odbc_driver()
// {
// $this->_random_keyword = ' RND('.time().')'; // database specific random keyword
// }
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
// Not needed for ODBC
return TRUE;
}
2 none of my active record queries worked when I was connecting to mssql because everything was being backticked
and 3 tables where being bracketed
So I modified the following
Code:
/**
* Protect Identifiers
*
* This function adds backticks if appropriate based on db type
*
* @access private
* @param mixed the item to escape
* @param boolean only affect the first word
* @return mixed the item with backticks
*/
function _protect_identifiers($item, $first_word_only = FALSE)
{
return $item;
}
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if (! is_array($tables))
{
$tables = array($tables);
}
return implode(', ', $tables);
}
What I suggest is that the odbc be looked at and make it the simplest possible standard SQL so that it will run in almost anything with no issues
And an idea for things like the _from_tables and _protect_identifiers is that you could store the backtick and bracketing values as properties of the object
That way at run time, if required someone could set the values to an empty string and the process would still work
i.e.
Code:
var $_from_brackets = array('(',')');
var $_protection = array('`','`');
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if (! is_array($tables))
{
$tables = array($tables);
}
return $this->_from_brackets[0].implode(', ', $tables).$this->_from_brackets[1];
}
As you can see this way by default it will return
Code:
(`TABLE1`, `TABLE2`)
but if I was then to empty the values
Code:
$this->_from_brackets = array('','');
$this->_protection = array('','');
it would return
This would make things a little bit more configurable at run time.