I'm having a problem I've never seen in php, I'll try to set an example to make it easier to understand.
I have a arquivos
table in this table I have 2 columns being id do arquivo
and id do usuário
(to whom this file belongs).
The user of id
8 is connected and in the system will list all files that have idUsuario
8 that are 4 files related to even just that my method of listing files always omitted a sample file are 4 files registered with idUsuario
8 it does not list me 4 files it is listing me 3 ie a file it
So I understand interpreting the output it is taking the amount of data that a given user has and always omitting the file of smaller id of the table
method listArchives
public function listarArquivo(){
try{
$id_usuario = $this->id;
$query = new DbFunctions();
$query->selectFiles("SELECT * FROM arquivos WHERE idUsuario = '$id_usuario'");
//var_dump($id_usuario);
foreach($query->getResult() as $chave => $dado){
echo "<tr>
<td>".$dado->id_arquivo."</td>
<td>".$dado->nome."</td>
<td>".$dado->tamanho."</td>
<td>".$dado->data."</td>
<td>
<a href='visualizar_arquivo.php?acao=visualizar&id_arquivo=".$dado->id_arquivo."'target='_blank'><i class='fa fa-external-link fa-2x' aria-hidden='true'></i></a>
<a href='visualizar_arquivo.php?acao=download&id_arquivo=".$dado->id_arquivo."'target='_blank'><i class='fa fa-cloud-download fa-2x' aria-hidden='true'></i></a>
<a href='?link1=".$dado->id_arquivo."' name='link1' ><i class='fa fa-trash fa-2x' aria-hidden='true'></i></a>
</td>";
}
//$query->getResult();
echo "<pre>";
var_dump($query->getResult());
echo "</pre>";
}catch(PDOException $e){
echo $e->getMessage();
}
}
selectFiles method:
public function selectFiles($sql){
$query = $this->conecta()->query($sql);
foreach($query as $row){
$this->setResult($query->fetchAll(\PDO::FETCH_OBJ));
//$this->setResult($row);
return true;
}
}
I do not know if this problem could be because I'm getting the result of the query and putting it on an object, would that object have a storage size?
It may be a bit confusing for me, but I do not understand the reason for this problem if someone can give me some help, thank you.