我创建了一个这样的存储过程,并使用输入参数调用该过程。我想在正常情况下使用参数调用它时获得它自己的过程,就像回声查询一样。
$procedure = "CREATE PROCEDURE pdruser_login(IN userName VARCHAR(300), IN password VARCHAR(500))
BEGIN
DECLARE _sqlQuery VARCHAR(2046);
SET _sqlQuery = 'SELECT login_id, authorized, admin_authorize FROM tbluser_login WHERE user_name = userName AND user_pwd = password AND authorized = 1 AND privacy_policy = 1 AND is_deleted = 0';
SET @sqlQuery = _sqlQuery;
PREPARE dynquery FROM @sqlQuery;
EXECUTE dynquery;
DEALLOCATE PREPARE dynquery;
END;";
if (!mysqli_query($this->con,"DROP PROCEDURE IF EXISTS pdruser_login") ||!mysqli_query($this->con,$procedure))
{
file_put_contents("minefile1.txt", "Stored procedure creation failed: (" . mysqli_errno($this->con) . ") " . mysqli_error($this->con));
}
if (!($result = mysqli_query($this->con,"CALL pdruser_login('".$userName."','".$password."'")))
{
file_put_contents("minefile2.txt","CALL failed: (" . mysqli_errno($this->con) . ") " . mysqli_error($this->con));
}
但是上面的过程显示了一个错误“CALL failed: (1064) You have an error in your SQL syntax;检查与您的 MySQL 服务器版本相对应的手册,以便在第 1 行的 '' 附近使用正确的语法”。
如何在调用存储过程时显示存储过程查询。有没有办法获取动态查询,以便轻松跟踪复杂查询中的错误?