catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

ORDER RAND() not working #133

Closed omphteliba closed 10 years ago

omphteliba commented 10 years ago

Hi,

i can't get "ORDER RAND()" to work. When i add it with

"ORDER"=>"RAND()"

the query produced looks something like that:

SELECT "screen_name" FROM "users" WHERE "screen_name" != '' ORDER BY "RAND" LIMIT 100

but i want "ORDER BY RAND()"

Am i doing it wrong?

saotand commented 10 years ago

try with:

"#ORDER"=>"RAND()"

then it will not quote the SQL Command... :)

omphteliba commented 10 years ago

Ah, ok. Thx!

jasonlav commented 8 years ago

This solution does not work with the latest version of medoo.

hlo2109 commented 6 years ago

Esto es para la última versión la dejo aquí para seguir el hilo

'ORDER' => Medoo::raw('RAND()')

Si tienen una clase y dentro incluye su base de datos seria algo asi 'ORDER' => $this->db->raw('RAND()')

https://medoo.in/api/raw