1

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

LINKeRxUA
  • 559
  • 6
  • 26
  • Possible duplicate of [how to execute mysql command DELIMITER](http://stackoverflow.com/questions/5311141/how-to-execute-mysql-command-delimiter) – kero Oct 21 '15 at 14:53
  • [This post](http://forum.kohanaframework.org/discussion/4784/how-to-do-a-mysqli-multi_query/p1) from the official Kohana forum might help as well (tl;dr: `multi_query` is not supported by Kohana) – kero Oct 21 '15 at 14:54
  • yep! You was right! It' works without delimiter. Please, post a reply as "delimiter is not mysql command, it's command of shell. Try to use array of queries ignoring delimiter" to I can mark it as solution for my question. Thanks a lot! – LINKeRxUA Oct 22 '15 at 10:43

1 Answers1

3

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)

Community
  • 1
  • 1
kero
  • 10,647
  • 5
  • 41
  • 51