Search code examples
mysqlkohanadelimiterkohana-3kohana-3.3

How to change mysql Delimiter inside Kohana framework during call one model method?


I have one method that must create mysql procedure, and run it. The problem is to change delimiter

public function doSomeThing(){
    $run = array();
    $run[] = DB::query(null, "DELIMITER $$");
    //... here we continue of pushing more commands
    /**
     * @var Database_Query[] $run
     */
    foreach($run as $command){
        $command->execute();
    }
}

I see exception:

Database_Exception [ 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 'DELIMITER $$' at line 1 [ DELIMITER $$ ]

What i'm doing wrong? Thanks


Solution

  • As you can see in this answer, you cannot use the DELIMITER via PHP as it is a command line statement. Just leave it out and use an array of queries (Kohana sadly does not support multiple queries via one call to the DB)