2016-03-28 113 views
0

我試圖爲我的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

文件名正確的語法手冊: /家庭/項目/控制器/管理/設置.PHP

行號:37

我在做什麼錯在這裏?

+0

爲了初始化實用工具類,你的數據庫驅動必須已經運行,因爲公用事業類依賴於它。 – sandeepsure

+0

@sandeepsure我不明白!我該怎麼做 ?我已經加載$ this-> load-> dbutil();這但我怎麼能讓db驅動程序運行? – Rajan

+0

你可以把它做成單桌嗎? – sandeepsure

回答

-1

在寫入選擇查詢後,在表名之前和之後添加。

例如:

SELECT * FROM `28e22aafcb89a2b83643700c3f2044de` 
+0

我還沒有硬編碼這個查詢 – Rajan

+0

dbutil庫怎麼樣? –

+0

我已將它加載到我的基本控制器中@akhil – Rajan

相關問題