developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 12 years ago

Last modified 8 years ago

#661 confirmed enhancement

jDao should be able to "order by rand()"

Reported by: greut Owned by:
Priority: normal Milestone:
Component: jelix:dao Version: 1.0.5
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:

Description

I'd like to be able to do this:

<?php
// ...
$conditions->addItemOrder("rand()");

See there you go:

diff -r 7926988cdd03 www/lib/jelix/dao/jDaoFactoryBase.class.php
--- a/www/lib/jelix/dao/jDaoFactoryBase.class.php       Tue Aug 12 18:51:17 2008 +0200
+++ b/www/lib/jelix/dao/jDaoFactoryBase.class.php       Wed Aug 13 16:39:00 2008 +0200
@@ -332,6 +332,8 @@
         foreach ($daocond->order as $name => $way){
             if (isset($props[$name])){
                 $order[] = $name.' '.$way;
+            } else if(strtoupper($name) === "RAND()") {
+                $order[] = $name;
             }
         }

Thanks,

-- Yoan

Change History (4)

comment:1 Changed 12 years ago by black_jack

comment:2 Changed 12 years ago by laurentj

  • Component changed from jelix to jelix:dao

comment:3 Changed 9 years ago by laurentj

  • Status changed from new to confirmed
Note: See TracTickets for help on using tickets.