数据库恢复问题触发器和存储过程(Mysql / Codeigniter)

We are using single source with multiple database concept. I am trying to restore db(.sql file) to client database, all tables restore fine except trigger and stored procedure.

Our view

enter image description here

Controller

public function import_database(){ 
$data = $this->input->post();
        if(!empty($data)) 
            {
            $config_app = array(
            'hostname' => 'localhost',
            'username' => 'root',
            'password' => '',
            'database' => $data['cmp_db_name'],
            'dbdriver' => 'mysqli',
            'dbprefix' => '',
            'pconnect' => FALSE,
            'db_debug' => TRUE
            );
            $this->db =$this->load->database($config_app,TRUE); // open client database connection
                        $filename=$_FILES["database"]["tmp_name"];      
                        $templine = '';
$lines = file($filename);
 foreach ($lines as $line)
{
if (substr($line, 0, 2) == '--' || $line == '')
continue;
$templine .= $line;
if (substr(trim($line), -1) == ';')
{
$this->db->query($templine);
$templine = '';
}
}
}
}

I got the following error:

Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DELIMITER $$ CREATE DEFINER=root@localhost PROCEDURE audt_pro (IN coumn_n' at line 1 DELIMITER $$ CREATE DEFINER=root@localhost` PROCEDURE audt_pro (IN coumn_nm TEXT, IN deleted_id TEXT, IN tbl_nm VARCHAR(50)) BEGIN DECLARE qry text;

doueta6642
doueta6642 在此处发布sql文件中的内容,在粘贴之前首先删除带有用户敏感数据的插入。
大约 2 年之前 回复
dongweng6241
dongweng6241 得到错误:错误号:1064您的SQL语法有错误;查看与您的MariaDB服务器版本对应的手册,以便在'DELIMITER附近使用正确的语法'CREATEDEFINER=root@localhostPROCEDUREaudt_pro(第1行的INcoumn_n'DELITITER$$CREATEDEFINER=root@localhost`PROCEDUREaudt_pro(INcoumn_nmTEXT,INdeleted_idTEXT,INtbl_nmVARCHAR(50))BEGINDECLAREqrytext;
大约 2 年之前 回复
doubu4826
doubu4826 有意思,兄弟。感谢您分享状态报告。对于包含分号字符的MySQL存储程序,我们需要在执行例如分号时使用分号以外的语句分隔符。CREATEPROCEDURE语句。(看起来问题中的代码会在遇到的第一个分号字符处删除CREATEPROCEDURE语句。
大约 2 年之前 回复
dtrt2368
dtrt2368 你有问题吗?
大约 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐