CodeIgniter Forums

Full Version: Database Backup with Reserved Keyword
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]TigerWolf[/eluser]
The Bug

I found this error when trying to backup my database:

Code:
A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order' at line 1

SELECT * FROM order

This is because one of my table names ("Order") is a mysql reserved word. This broke the database backup. If I deleted this table the problem went away.

I went digging in the code and found where the problem was:

The Fix

If you check out line 132 of mysql_utility in system/database/drivers/mysql - This line appears:

Code:
$query = $this->db->query("SELECT * FROM $table");
Changing it to

Code:
$query = $this->db->query("SELECT * FROM `$table`");

Fixes the problem mentioned above.

Thanks.

So what should I do next?