Welcome Guest, Not a member yet? Register   Sign In
$this->dbforge->drop_table() problem.
#1

[eluser]J. Pavel Espinal[/eluser]
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
#2

[eluser]Pascal Kriete[/eluser]
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.
Code:
$this->dbforge->drop_table('databasename.15-test003');

Another solution that might work:
Code:
$this->dbforge->drop_table('`15-test003`');
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB