Welcome Guest, Not a member yet? Register   Sign In
How to set up this to NOT use foreach?
#1

[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,
#2

[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?




Theme © iAndrew 2016 - Forum software by © MyBB