Hello Cookers,
I am facing a little problem with a query. I want to display a random selection of products (9 out of 20).
Before ORM, this code works like a charm:
// LIMIT
$this->setState('list.limit', 9);
// ORDER
$this->addOrder( 'rand()' );
Query Result : ORDER BY rand(), a.dname asc;
Now, I am trying to update my code with ORM but the RAND() do not work (no warning, no error) but ORDER BY is default.
My code :
// LIMIT
$this->setState('list.limit', 9);
// ORDERING
$orderCol = $this->getState('list.ordering', 'dname');
$orderDir = $this->getState('list.direction', 'RAND()');
$this->orm->order(array($orderCol => $orderDir));
break;
Query Result: ORDER BY a.dname ASC;
Any idea to hold that, chief ?