CodeIgniter Forums
Database Backup with Reserved Keyword - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Database Backup with Reserved Keyword (/thread-33002.html)

Database Backup with Reserved Keyword - El Forum - 08-11-2010

The Bug

I found this error when trying to backup my database:

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


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:

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

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

Fixes the problem mentioned above.


So what should I do next?