I'm selecting something in mySQL via PHP and that command returns some array (which is right), but when I put that returning SELECT inside if condition and ask if it is returning null than PHP says it is returning null (which is not right, because it is returning array)
include '../db.php'; // my config
function select($command) {
global $db;
$sql = "".$command."";
$sqlDone = $db -> prepare($sql);
$sqlDone -> execute();
$data = $sqlDone -> fetchAll();
return $data;
}
$select = "SELECT likes.ID, likes.ID_user, likes.ID_post FROM likes WHERE likes.ID_user = '53' AND likes.ID_post = '2'"
if (select($select) == null) { // goes throw this
print_r(select($select)); // returns array
} else {
echo 'not null';
}
I tried to use !is_null and it doesn't work anyway. I tried to put that select command with same values directly inside phpmyadmin and it returns array, so I'm confused. Can you help me out?

print_rthe data if not null instead of just printing "not null" ?===) instead of (==). An empty array is "falsy" in PHPselect()function, why do you need it? Seems needlessly complicated to me, and a few of the lines in there do nothing at all.