Welcome Guest, Not a member yet? Register   Sign In
SQLite Driver -- SELECT FROM Table List Issue
#1

[eluser]Unknown[/eluser]
Hi folks,

Just started using CI the other day, and ran into a little bump along the way. I'm using SQLite 2 at the moment, and it seems that it does not support the format:

Code:
SELECT * FROM (table1, table2) WHERE ...

Note the parentheses there. I'm not quite sure how SQLite is parsing the grammar here -- nor am I great with SQL -- but it appears that parentheses aren't supported as a method of grouping, and in fact indicate a sub-select query to SQLite. See http://www.sqlite.org/lang_select.html for the SQLite parsing information if you can suss it out.

This behavior is also present in the SQLite 3 command-line-interface, but since I'm using PHP4, I haven't checked with the user-supplied PDO interface library.

Anyway, this parenthesied output is the type of SQL that sqlite_driver.php produces in its _from_tables function:

Code:
/**
     * 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).')';
    }

To have a working query we just have to change that return line to:

Code:
return implode(', ', $tables);

Hope this helps someone else out there...

-Tony Wooster
#2

[eluser]jpwilksch[/eluser]
Thankyou Tony!

After many hours of debugging the same issue, I also came to this conclusion. Unfortunately, only once I knew the fix did an appropriately worded search return your post :-(

This bug still exists in CodeIgnitier 1.7.2, and by the look of it has existed since version 1.6.0 or earlier.




Theme © iAndrew 2016 - Forum software by © MyBB