Part of the EllisLab Network
   
 
$this->dbforge->drop_table() problem. 
Posted: 30 June 2008 03:17 PM   [ Ignore ]  
Summer Student
Total Posts:  3
Joined  02-08-2008

Hello,

I’m facing a problem when I try to drop a table called ‘15-test003’. The query generated by
$this->dbforge->drop_table() function is this:

DROP TABLE IF EXISTS 15-test003

...which returns an error also using phpMyAdmin. The following queries produce errors too:

DROP TABLE IF EXISTS ‘15-test003’
DROP TABLE IF EXISTS “15-test003”

The following query successfully drops the table:

DROP TABLE IF EXISTS `15-test003`

Have anyone faced similar problems while work with unusual names for tables?
Is this a bug? .. or (as I suspect) I should not use names like that for Tables?

Thanks,

--
Jose P. Espinal

 Signature 

--
Jose P. Espinal
http://blog.slackware-es.com

Profile
 
 
Posted: 30 June 2008 03:31 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1089
Joined  01-07-2008

I’m pretty sure it’s hyphen in your table name.  Try prefixing it with the database name, as the usual rule is that if there is a period, the following word is an identifier and needs not be quoted.

$this->dbforge->drop_table('databasename.15-test003');

Another solution that might work:

$this->dbforge->drop_table('`15-test003`');

 Signature 

Blog | Twitter | Coffee

Profile
 
 
Posted: 30 June 2008 03:44 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  1
Joined  01-25-2008

Thanks for the quick reply!

I will use one of the possible solutions or try to use ‘_’ instead of ‘-’,

This is not a ‘bug’, right?. Its just a bad name from my part xD

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 719, on June 06, 2008 10:16 AM
Total Registered Members: 61059 Total Logged-in Users: 31
Total Topics: 73869 Total Anonymous Users: 1
Total Replies: 398479 Total Guests: 361
Total Posts: 472348    
Members ( View Memberlist )
Newest Members:  bnolenstanjadebieSan2kakifemreSchottec2kmeenazterjinFuadgeorge_k_allis