I have a query that checks if a row from a table exists. It should return a 'true' or 'false' value, but this is not the case.
The query and code look as follows. I should mention that I use the CodeIgniter framework, hence the object names and function names.
$query="SELECT CASE WHEN EXISTS
(
SELECT * FROM Users
WHERE Email=".$this->db->escape($email)."
AND PassWord=MD5(".$this->db->escape($password).")
)
THEN 'TRUE'
ELSE 'FALSE'
END";
$result=$this->users_db->query($query);
$resulting_array=$result->row();
echo "<pre>".var_dump($resulting_array)."</pre>";
This code gives the following result:
object(stdClass)#22 (1) {
["CASE WHEN EXISTS
(
SELECT * FROM Users
WHERE Email='r.blaauwen@erasmusmc.nl'
AND PassWord=MD5('rrt')
)
THEN 'TRUE'
ELSE 'FALSE'
END"]=>
string(5) "FALSE"
}
It seems $result->row();
delivered an object instead of an array/string/boolean. The 'FALSE' result is there, but I don't know how to retrieve it.