我有一个查询,它检查数据库是否与输入的用户名和密码匹配,此查询的相应值将是 0(不匹配)或 1(匹配)。这将在具有一个值(1 或 0)的列 (itDoesExist) 中输出。
我想知道的是如何在 PHP 中获得该值?我想我在这里遗漏了一些东西,我似乎无法弄清楚那是什么。
这是代码:
$stmt = $link->prepare("
SELECT CASE WHEN
EXISTS (
SELECT 1
FROM user_details
INNER JOIN user_info
ON user_details.id = user_info.id
WHERE user_info.emailContact = ?
AND user_details.password = ?
)
OR EXISTS (
SELECT 1
FROM user_details
INNER JOIN user_business_info
ON user_details.id = user_business_info.id
WHERE user_business_info.emailContact = ?
AND user_details.password = ?
)
THEN 1
ELSE 0
END AS itDoesExist
");
if (!$stmt)
{
$error = "{$link->errno} : {$link->error} (Error Searching For User)";
include "C:/wamp/www/includes/html/main/error.html.php";
exit();
}
if (!$stmt->bind_param("ssss", $username, $password, $username, $password))
{
$error = "{$stmt->errno} : {$stmt->error}";
include "C:/wamp/www/includes/html/main/error.html.php";
exit();
}
if (!$stmt->execute())
{
$error = "{$stmt->errno} : {$stmt->error} (Cant execute?)";
include "C:/wamp/www/includes/html/main/error.html.php";
exit();
}
提前感谢您在这方面的任何帮助或信息!