I\'m using mysqli and trying now to get a view from an SQL code snippet (generated by MySQL Workbench) into a database.
$query = <<
This is the source that helped me understand this... http://zend-framework-community.634137.n4.nabble.com/Problems-changing-the-sql-end-of-statement-delimiter-tp2124060p2124276.html
DELIMITER is not an actual MySQL Statement.
I believe it is just something that some MySQL clients have implemented to help shipping a bunch of sql statements at the same time.
mysqli driver does not implement this functionality.
So, this should work.
$query = <<<QUERY
DROP VIEW IF EXISTS `myview` ;
SHOW WARNINGS;
DROP TABLE IF EXISTS `myview`;
SHOW WARNINGS;
CREATE OR REPLACE VIEW `myview` AS
...view definition...
;
SHOW WARNINGS;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
QUERY;
$result = mysqli_multi_query($dbConnection, $query);
I ran into the same problem, with the same mysqli driver, with multi_query function (using delimiters while creating procedures) and removing the DELIMITER from my SQL worked.