我想知道这个存储过程是否正确。我试图在php中调用这个过程,它将两个绑定的varchar参数放到存储过程中。但是我收到了错误:
参数编号无效::名称
其中'name'是我正在使用的参数之一。
我的代码有什么问题?
CREATE OR REPLACE FUNCTION treasurehunt.huntlogin(character varying, character varying)
RETURNS bigint AS
$BODY$SELECT COUNT(*) FROM TreasureHunt.Player
WHERE name=$1 AND password=$2$BODY$
LANGUAGE sql VOLATILE
COST 100;
ALTER FUNCTION treasurehunt.huntlogin(character varying, character varying)
OWNER TO abro9592;
这是php
function checkLogin($name,$pass) {
// STUDENT TODO:
// Replace line below with code to validate details from the database
$db = connect();
try {
$stmt = $db->prepare('SELECT COUNT(*) FROM treasurehunt.huntlogin (:user,:pass)');
$stmt->bindValue(':name', $name, PDO::PARAM_STR);
$stmt->bindValue(':pass', $pass, PDO::PARAM_STR);
$stmt->execute();
$result = $stmt->fetchColumn();
$stmt->closeCursor();
} catch (PDOException $e) {
print "Error checking login: " . $e->getMessage();
return FALSE;
}
return ($result==1);
}