CodeIgniter Forums
How to set up this to NOT use foreach? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to set up this to NOT use foreach? (/showthread.php?tid=25476)



How to set up this to NOT use foreach? - El Forum - 12-13-2009

[eluser]Sinclair[/eluser]
Hi,

I need to do something like this:

Model:
Code:
function getTituloAnuncio($pid_anuncio) {
        $genero = $this->config->item('genero');
        $orientacao = $this->config->item('orientacao');
        $query = $this->db->query(" select a.n_anuncio
                                 from
                                            aa_anuncios a
                               where
                               a.id_anuncio = '1'");
        if ($query->num_rows() != 1) return FALSE;
        $result = $query->row_array();
        return $result['n_anuncio'];
    }

Controller:
Code:
$title = $this->Acomp_model->getTituloAnuncio($pid_anuncio = $this->uri->segment(3));

With this I avoid use FOREACH cycle.

Now I need to do this, but I have 2 database fields, so the Model is like this...

Model:
Code:
function getImagemDefeitoDetalhe($pid_anuncio) {
        $genero = $this->config->item('genero');
        $orientacao = $this->config->item('orientacao');
        $query = $this->db->query("select
                    a.id_anuncio, a.n_ficheiro
                    from
                    aa_anuncios a
                                            where id_anuncio = '1'");
        return $query->result();
    }

My question: What I need to change here to be able to access ID_ANUNCIO and N_FICHEIRO without using a foreach loop?


Best Regards,


How to set up this to NOT use foreach? - El Forum - 12-13-2009

[eluser]jedd[/eluser]
[quote author="Sinclair" date="1260752138"]
My question: What I need to change here to be able to access ID_ANUNCIO and N_FICHEIRO without using a foreach loop?
[/quote]

What foreach loop?