1
The SELECT
below when run directly in Phpmyadmin, returns all the results I want, but when I use in PHP function it comes empty:
$user = $_SESSION["usuario"]["id"];
$sel = BD::conn()->prepare("SELECT lk.*, ep.*
FROM gostados lk
INNER JOIN episodios ep ON
ep.id_anime = lk.id_anime AND
ep.ep_temporada = lk.ep_temporada AND
ep.episodio = lk.episodio
WHERE
lk.id_usuario = :user
ORDER BY data ASC
LIMIT 0,200");
$sel->bindValue(":user", $user);
$sel->execute();
$row = $sel->rowCount();
if($row >= 1){
echo "1";
}else{
echo "0";
}
I already checked the id of the user being used as bindValue
and it’s right, what could be the mistake that makes the $row
always return 0?
I just found the real root of the problem here while reading your code, the problem is in ORDER BY data, which should actually be Lk.data, but thank you so much for the tip from LEFT JOIN did not know it worked like this
– Leo Letto