MySQL & php PDO how to fetch: SELECT EXISTS (SELECT 1 FROM x WHERE y = :value) -
i'm using syntax instead of count (*) because it's supposed faster dont know how fetch resulting output
$alreadymember = $database->prepare('select exists ( select 1 thecommunityreachlinkingtable communitykey = :communitykey , userid = :userid)'); $alreadymember->bindparam(':communitykey', $_post['communitykey'], pdo::param_str); $alreadymember->bindparam(':userid', $_post['userid'], pdo::param_int); $alreadymember->execute(); if($alreadymember->fetch()) {do code here} but doesn't seems return correct, idea?
the use of exists seems wrong here. execute query instead:
select 1 thecommunityreachlinkingtable communitykey = :communitykey , userid = :userid
Comments
Post a Comment