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

[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:

Code:
$this->db->select('*');
$this->db->from('USERS');
$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 ')'.

SELECT * FROM (USERS) WHERE WEB_USERNAME = 'harry' AND WEB_PASSWORD = 'secret'

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.
#2

[eluser]tajinder.singh88[/eluser]
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
#3

[eluser]tedroche[/eluser]
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