5450 Posts in 1672 Topics by 1197 members
|Go to End|
22 July 2009 at 2:00pm Last edited: 22 July 2009 2:01pm
I want to get a random result from a quite specialised SQL query. I built the query simply using SQLQuery:
$sqlQuery = new SQLQuery();
$sqlQuery->select = array( ... etc ... );
$sqlQuery->from = array( ... etc ...);
... etc ...
$sqlQuery->orderBy = 'RAND()';
Works all perfectly except $sql->orderBy = 'RAND()';
If I order by a specific field it's fine, but ORDER BY RAND() simply gets stripped out of the query when I run
Do I do anything wrong or is RAND() simply not supported as an orderby value? If it's not supported may I suggest to include this in a future version of Silverstripe?
|Go to Top|