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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -