Welcome Guest, Not a member yet? Register   Sign In
CI ODBC driver adding round brackets around table names

[eluser]Andy Chapman[/eluser]
Hi all, I'm using CI's odbc driver to connect to SQL Server (from unix using FreeTDS).

When I run a select statement like this:

$this->db->where('WEB_USERNAME', $username);
$this->db->where('WEB_PASSWORD', $password);

$query = $this->db->get();

I get a database error like this:

Error Number: 37000

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


If I manually remove the round brackets from the table name it works fine. I can also change the round brackets to square brackets and it works fine.

Any thoughts?

I'm using CI 1.7.2

Thanks in advance.

Try This:-

In function _from_tables($tables) under system/database/odbc/odbc_driver.php:-

remove parenthesis from return statement:-

Instead of:-
return '('.implode(', ', $tables).')';
It should be:-
return implode(', ', $tables);

This works brilliantly for me. I hope it rocks for you as well.
Try it...All the best

Confirming this still appears to be a problem with the ODBC driver and SQL Server in version 1.7.3

Theme © iAndrew 2016 - Forum software by © MyBB