Welcome Guest, Not a member yet? Register   Sign In
db->get('entries') producing SELECT * FROM (entries) which causes an error 42000 on SQL Server 2005
#1

[eluser]Unknown[/eluser]
I'm using an ODBC database connection on a Mac to an SQL Server 2005 machine. I'm using the demo blog example from the video.

A Database Error Occurred
Error Number: 42000

[FreeTDS][SQL Server]Incorrect syntax near ')'.

SELECT * FROM (entries)

When I try run that select statement directly in my SQL Server machine it complains about the parenthesis as well. It needs to be:

SELECT * FROM entries

Thanks in advance for any redirection/advice if this is user configurable or something.
#2

[eluser]cwt137[/eluser]
you don't need the parenthesis
#3

[eluser]Unknown[/eluser]
I know, they are automatically added - that query is autogenerated - how do I get rid of them?
#4

[eluser]cwt137[/eluser]
please post your code so we can see what's wrong.
#5

[eluser]Unknown[/eluser]
The bug is in db/drivers/odbc/odbc_driver.php
Code:
function _from_tables($tables)
    {
        if ( ! is_array($tables))
        {
            $tables = array($tables);
        }
        
        return '('.implode(', ', $tables).')';
    }

The brackets should be configurable, I think, because the tables are enclosed in different characters for different databases.




Theme © iAndrew 2016 - Forum software by © MyBB