[eluser]imn.codeartist[/eluser]
[quote author="Sinclair" date="1255824516"]Hi,
I'am with some dificulty in using 2 model functions inside one view.
Model functions to use:
Code:
function getAnuncioDetalheActivo($pid_anuncio) {
$query = $this->db->query("select e.id_anunciante, e.n_anunciante, e.nome_abrev
from ate_anunciantes e, atw_anuncios a, atp_pag_anuncios pa
where
a.id_anuncio = pa.id_anuncio and
a.id_anunciante = pa.id_anunciante and
e.id_anunciante = a.id_anunciante and
pa.dat_inicio <= NOW() and
pa.dat_fim >= NOW() and
a.id_anuncio = '".$pid_anuncio."'");
return $query->result();
}
function getServicosAnuncioDetalheActivo($pid_anuncio) {
$query = $this->db->query("select s.n_servico
from atw_anuncios a, atp_pag_anuncios pa, atw_servicos_anuncios sa, atw_servicos s
where
a.id_anuncio = pa.id_anuncio and
a.id_anunciante = pa.id_anunciante and
a.id_anuncio = sa.id_anuncio and
a.id_anunciante = sa.id_anunciante and
sa.id_servico = s.id_servico and
pa.dat_inicio <= NOW() and
pa.dat_fim >= NOW() and
a.id_anuncio = '".$pid_anuncio."'");
return $query->result();
}
Here is my controller:
Code:
function detalhe($pid_anunciante) {
$this->load->model('acomp_model');
$data['result'] = $this->acomp_model->getAnuncioDetalheActivo($pid_anuncio = $this->uri->segment(3));
$data2['result'] = $this->acomp_model->getServicosAnuncioDetalheActivo($pid_anuncio = $this->uri->segment(3));
$this->load->view('detalhe_view', $data);
$this->load->view('detalhe_view', $data2);
}
I know thar the code in the controller is not correct, but how can I read the 2 model function to one view?
Here is the view:
Code:
foreach($result as $row) {
echo $row->id_anunciante; echo '<br />';
echo $row->n_anunciante;
/* echo anchor('anuncios/zona/' . $row->id_zona, $row->id_zona); */
}
If you can help me, please reply.
Best Regards,[/quote]
Here is the solution of your problem
Make some changes in your controller as follows:
Code:
function detalhe($pid_anunciante) {
$this->load->model('acomp_model');
$data['result'] = $this->acomp_model->getAnuncioDetalheActivo($pid_anuncio = $this->uri->segment(3));
$data['result1'] = $this->acomp_model->getServicosAnuncioDetalheActivo($pid_anuncio = $this->uri->segment(3));
$this->load->view('detalhe_view', $data);
}
Here is the view:
Code:
foreach($result as $row) {
echo $row->id_anunciante; echo '<br />';
echo $row->n_anunciante;
/* echo anchor('anuncios/zona/' . $row->id_zona, $row->id_zona); */
}
Code:
foreach($result1 as $row) {
// echo your second result here
}
Hope this will make sense to you.