且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

执行mysql“create function”声明与PHP

更新时间:2023-11-30 11:46:04

You most likely do not need the DELIMTER command. That belongs to MySQL-centric client programs.

Please try with plain old semicolons:

if (!$mysqli->query("DROP PROCEDURE IF EXISTS p") ||
    !$mysqli->query("CREATE PROCEDURE p(IN id_val INT) BEGIN INSERT INTO test(id) VALUES(id_val); END;")) {
    echo "Stored procedure creation failed: (" . $mysqli->errno . ") " . $mysqli->error;
}

and let PHP worry about delimiting

CAVEAT

I got the above code from http://php.net/manual/en/mysqli.quickstart.stored-procedures.php