Part of the EllisLab Network
   
 
db->get(‘entries’) producing SELECT * FROM (entries) which causes an error 42000 on SQL Server 2005
Posted: 05 May 2009 12:47 PM   [ Ignore ]  
Summer Student
Total Posts:  2
Joined  05-05-2009

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.

Profile
 
 
Posted: 05 May 2009 03:15 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  63
Joined  01-18-2009

you don’t need the parenthesis

Profile
 
 
Posted: 06 May 2009 09:59 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  2
Joined  05-05-2009

I know, they are automatically added - that query is autogenerated - how do I get rid of them?

Profile
 
 
Posted: 06 May 2009 12:33 PM   [ Ignore ]   [ # 3 ]  
Grad Student
Rank
Total Posts:  63
Joined  01-18-2009

please post your code so we can see what’s wrong.

Profile
 
 
Posted: 30 June 2009 01:48 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  1
Joined  06-30-2009

The bug is in db/drivers/odbc/odbc_driver.php

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.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120533 Total Logged-in Users: 30
Total Topics: 126595 Total Anonymous Users: 5
Total Replies: 665538 Total Guests: 405
Total Posts: 792133    
Members ( View Memberlist )
Newest Members:  rachel123Rach123Glenn StavaImfaelSMS!persanulandrewknightKittx77AmityBetbul