I'm using mysqli and trying now to get a view from an SQL code snippet (generated by MySQL Workbench) into a database.
$query = <<<QUERY
DROP VIEW IF EXISTS `myview` ;
SHOW WARNINGS;
DROP TABLE IF EXISTS `myview`;
SHOW WARNINGS;
DELIMITER $$
CREATE OR REPLACE VIEW `myview` AS
...view definition...
$$
DELIMITER ;
;
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);
This doen't work. No errors, the statement seems just to be ignored. It only works, if I remove the delimiter definitions (lines DELIMITER $$
, $$
, and DELIMITER ;
).
Why is it not working? What can/should I do to use delimiters in SQL statements passed to mysqli
functions and methods?
Thx
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…