CodeIgniter Forums
CI ODBC driver adding round brackets around table names - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: CI ODBC driver adding round brackets around table names (/thread-29969.html)



CI ODBC driver adding round brackets around table names - El Forum - 04-27-2010

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


CI ODBC driver adding round brackets around table names - El Forum - 10-23-2010

[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


CI ODBC driver adding round brackets around table names - El Forum - 02-01-2011

[eluser]tedroche[/eluser]
Confirming this still appears to be a problem with the ODBC driver and SQL Server in version 1.7.3