我正在尝试为我的Codeigniter应用程序备份我的数据库。我使用了CI的用户指南中的代码,如下所示:
public function db_backup()
{
$prefs = array(
'tables' => array(), // Array of tables to backup.
'ignore' => array(), // List of tables to omit from the backup
'format' => 'txt', // gzip, zip, txt
'filename' => 'mybackup.sql', // File name - NEEDED ONLY WITH ZIP FILES
'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file
'add_insert' => TRUE, // Whether to add INSERT data to backup file
'newline' => "\n" // Newline character used in backup file
);
$this->dbutil->backup($prefs);
// Load the DB utility class
// Backup your entire database and assign it to a variable
$backup =& $this->dbutil->backup();
// Load the file helper and write the file to your server
$this->load->helper('file');
write_file('/uploads/mybackup.zip', $backup);
// Load the download helper and send the file to your desktop
$this->load->helper('download');
force_download('mybackup.zip', $backup);
}
我在我的本地服务器上尝试了这个代码并且它工作得非常好,但是当我在实时服务器上尝试相同时,它会显示我这样的错误:
发生数据库错误
错误号码:1064
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近' 28e22aafcb89a2b83643700c3f2044de'在第1行
SELECT * FROM 28e22aafcb89a2b83643700c3f2044de
文件名: /home/project/controllers/admin/setting.php
行号:37
我在这里做错了什么?
答案 0 :(得分:-1)
写这个选择查询时,在表名之前和之后添加`。
例如:
SELECT * FROM `28e22aafcb89a2b83643700c3f2044de`