Welcome Guest, Not a member yet? Register   Sign In
CI 1.6 odbc driver issues
#1

[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
Code:
TABLE1, TABLE2

This would make things a little bit more configurable at run time.
#2

[eluser]Morty[/eluser]
That might be the same issue as I am currently faced with. Just updated from 1.5.4 to 1.6.2, now every MSSQL query fails.

I will try your solution and report back.
#3

[eluser]Jacob156[/eluser]
I ran into the same problem with 1.6.2. Commented out the constructor after finding this post and everything worked great.

Looking thru the bug reporter I found they already fixed the backtick problem.

Using XAMPP on Windows XP.




Theme © iAndrew 2016 - Forum software by © MyBB