Tenho que concordar que na documentação não ficou claro.

olhando em system/database/DB_active_rec.php linha 763

vi que a string "random" deve ser passado como segundo argumento e não
importará o primeiro argumento.

Se passar assim:
$this->db->order_by('rand()');
obterás:
order by `rand()` //porque o ci vai formatar o rand() como se fosse coluna


então fica:
$this->db->order_by("", "random");
ou
$this->db->order_by("nada_aqui_fara_direferenca_se_o_argumento_seguinte_for_random",
"random");

No Change Log do 1.6.0
Added 'random' as an order_by() option , and removed "rand()" as a
listed option as it was MySQL only.


Abs
Edinho Almeida






On Thu, Apr 3, 2008 at 11:32 AM, Marco Telles
<[EMAIL PROTECTED]> wrote:
> Renato
>
> CodeIgniter User Guide Version 1.6.1
>
>
> > $this->db->order_by();
> >
> > Lets you set an ORDER BY clause. The first parameter contains the name
> > of the column you would like to order by. The second parameter lets you
> > set the direction of the result. *Options are asc or desc, or random.*
> > $this->db->order_by("title", "desc");
> >
> > // Produces: ORDER BY title DESC
> >
> > You can also pass your own string in the first parameter:
> > $this->db->order_by('title desc, name asc');
> >
> > // Produces: ORDER BY title DESC, name ASC
> >
> > Or multiple function calls can be made if you need multiple fields.
> >
> > $this->db->order_by("title", "desc");
> > $this->db->order_by("name", "asc");
> >
> > // Produces: ORDER BY title DESC, name ASC
> >
>
> Vê se ajuda... ;) E olha que eu ando enxergando mal... heheheheh
>
> Muita sorte para nós!
>
> Marco Telles
>
>
>
>
> Renato Costa Barbosa escreveu:
>
> > Opa
> > Yeah, li sim,
> > eu estyou usando a 1.6.1 e procurei na sessão Database Library, me
> > apeguei mais no tópico active record, mas na pesquisa inteira, eu num
> > achei nada fala fale sobre o rand
> > Normalmente eu uso o sql dessa forma SELECT * FROM table ORDER BY
> > RAND(), apenas para randomizar sem nenhum tratamento
> >
> >
>
>
>
>
>
> _______________________________________________
> Lista mailing list
> [email protected]
> http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br
>



-- 
Abs
Edinho Almeida
11 3711-7074
11 3564-8906

_______________________________________________
Lista mailing list
[email protected]
http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br

Responder a