I'm having some troubles when i get data of one of my table.
I'm using Doctrine 1 + Codeigniter and the problems is that the data obtains only the last one registry.
I don't have define any relation between this tables (OpModelos and AnSimNavTrans) and this is the scenery:
Controller:
class Modelos extends CI_Controller {
public function view($idModelo) {
$aData['site_description'] = 'AutoDato';
$aData['site_keywords'] = 'keywords';
$aData['site_robots'] = 'robots';
$aData['site_author'] = 'author';
$modelo = Doctrine::getTable('OpModelo')->find($idModelo);
$modelo_caract = Doctrine::getTable('anCaractUserMo')->getByModeloId($idModelo);
$modelos_similares_nav = Doctrine::getTable('OpModelo')->getModeloSimNav($idModelo);
$aData['modelo'] = $modelo;
$aData['modelo_caract'] = $modelo_caract;
$aData['modelos_similares_nav'] = $modelos_similares_nav;
$aData['view'] = 'modelo/view';
$this->load->view('template', $aData);
}
}
data table AnSimNavTrans
op_modelo_id cod_mod med_sim
1 10 0.9
1 2 0.8
1 11 0.7
1 4 0.5
1 6 0.1
Model
class OpModeloTable extends Doctrine_Table {
public function getModeloSimNav($idModelo) {
$query = Doctrine_Query::create();
$query->from('AnSimNavTrans');
$query->where('op_modelo_id = ?', $idModelo);
$query->orderBy('med_sim DESC');
$query->limit('3');
$result = $query->execute();
return $result->toArray();
}
}
View:
print_r($modelos_similares_nav);
Array ( [0] => Array ( [op_modelo_id] => 1 [cod_mod] => 11 [med_sim] => 0.7 ) )
As you can see in view, when I get the array of the query, this only show the last record.
What its wrong with this?