I'm trying to join three tables from my database, being Propriedades | Licitacoes | Usuarios
. Only every time the same mistake is made! it is:
Fatal error: Call to a member function fetchAll() on a non-object in *** on line 61
The purpose for which I'm trying to join this table is to filter the information at the time of echo
, so much so that I'm using WHERE
at the end of the code. I want the user to enter the page in question only show the results related to it, this relation is given by the licitacoes
that the user owns and by the Nivel
that he has.
I've used pretty much the same code on another occasion and it has not given a similar error. I do not know why this is happening! Can you help me?
<?php
require_once "../conexao.php";
?>
<?php
$rs = $pdo->query(" SELECT a.ID as IDPROP, a.LICITI, a.NOME, a.NIVEL as NIPROP,
b.ID as IDLICI, b.ID_LICITI, b.ID_USER,
c.ID as IDCHAR, c.USUARIO, c.NIVEL as c.NICHAR
FROM propriedades a INNER JOIN licitacoes b on (a.LICITI = b.ID_LICITI)
INNER JOIN usuario c on (b.ID_USER = c.ID)
")->fetchAll();
if(!$rs){ print_r($pdo->errorInfo()); }foreach ($rs as $row){
?>
<?php echo $row['IDPROP'];?> = Informações da tabela propriedades
<?php echo $row['IDLICI'];?> = Informações da tabela licitacoes
<?php echo $row['IDCHAR'];?> = Informações da tabela usuario
<?php } ?>