我創建了一個像這樣的存儲過程,並用輸入參數調用該過程。我想在正常情況下使用echo參數調用它時自己獲取過程。調用過程時顯示存儲過程查詢
$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));
}
但上面的程序顯示錯誤「調用失敗:(1064)您的SQL語法錯誤;檢查對應於你的MySQL服務器版本使用附近的‘’在正確的語法手冊第1行「。
如何在調用存儲過程時顯示存儲過程查詢。是否有任何獲取動態查詢的方法,以便於在複雜查詢中跟蹤錯誤?