Take a look at this query:
SELECT count(case when apps_origin='backend' then 1 else null end) as
backend, count(case when apps_origin='frontend' then 1 else null end) as
frontend FROM appointments,users WHERE users.email='a25@hol.gr';
When run in the console it returns 1 for back-end and 0 for front-end implying that there is a row related to the value back-end and not a row related to the front-end.
And now the above query inside a function in the context of a prepared statement:
function check_pending_appt_buser($connection,$sessionmail)
{
if( $stmt_back = $connection->prepare('SELECT count(case when apps_origin="backend" then 1 else null end) as backend, count(case when apps_origin="frontend" then 1 else null end) as frontend FROM appointments,users WHERE users.email=?'))
{
$stmt_back->bind_param('s',$sessionmail);
$stmt_back->execute();
$row =$stmt_back->fetch();
return $row['backend'];
}
The above function returns NULL,I don’t get it…it should return 1,in accordance with the console results.