View all Model data in Zend Framework 1

0

The way I have this explorer I get only 1 data from each table, but I would like to understand how I would print it all.

 // Criamos o objeto do model da tabela 'carros'. 
 $carrosModel = new Application_Model_Carros();

 // Pegamos o carro de 'id' igual a 3.
 $carros = $carrosModel->fetchRow('id = 3');

 /*
 Estava pensando em criar esse foreach pegar o ID de cada um
 e fazer tipo igual fetchRow, mas minhas tentativas não deram certo.

 foreach ($carros as $carro)
 {
    $id = $carro->id;    
 }
 */

 // Aqui pegamos os campos das cores relativos ao carro de 'id'
 // igual a 3.
 $cores = $carros->findDependentRowSet('Application_Model_Cores');

 echo $carros->modelo;
 foreach($cores as $cor)
 {
    echo " -> " . $cor->cor;
 }
    
asked by anonymous 29.07.2014 / 21:05

1 answer

1

I did not quite understand your question. If you want to access the data of all cars you should use the fetchAll() method; Type

$select = $carrosModel->select(); 
$select->orderBy("id ASC");
$carros = $carrosModel->fetchAll($select);
foreach($carros as $carro){
echo $carro->id;
}

Give more details if it is not this.

    
29.07.2014 / 23:44