• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database Backup with Reserved Keyword

#1
[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?


Messages In This Thread
Database Backup with Reserved Keyword - by El Forum - 08-11-2010, 10:50 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.