0
Good morning, created a function to get the ids of all processes of a table, as shown in the code below
function getProcessos()
{
$conecta = new PDO('mysql:host=localhost; dbname=processos','root','root');
$sql = "SELECT id from processo where opcao='S' limit 10";
$resultado = $conecta->prepare($sql);
$resultado->execute();
$dados = $resultado->fetchAll(PDO::FETCH_OBJ);
return $dados;
}
Now I need to filter in the table movements by the processes obtained in the function above
$processo = getProcessos();
// var_dump($processo);
foreach ($processo as $linhas) {
$linha = $linhas->id;
$sql = "select * from andamento where idprocesso=$linha limit 10";
$stmt = $conecta->prepare($sql);
var_dump($stmt);
$stmt->execute();
$dados = $stmt->fetchAll();
// var_dump($dados);
}
when I give var_dump in $stmt it returns public 'queryString' => string 'select * from andamento Where idprocesso=5873, where it always modifies the idprocesses according to the getProcesso() function; However when I var_dump($data) it returns 10 empty arrays
Why not do it all in method only! in one SQL only!
– novic
idprocess='$line' tries so
– Wees Smith
Of a
var_dump($linha);
this will probably tell you a lot about the problem.– Guilherme Nascimento