Support > Elxis 2008 developers guide
Random ordering and ADODB
(1/1)
datahell:
If you wish to order randomly the results from the database then dont use "ORDER BY RAND()" as it is a native mysql function and only works on Elxis under MySQL. In this case you should use the $random variable of ADODB which is set automatically for every database type.
Instead of this:
$query = "SELECT........."
."\n ORDER BY RAND()";
Use this:
$randfunc = $database->_resource->random;
$query = "SELECT........."
."\n ORDER BY ".$randfunc;
The randomize function for MySQL is RAND() and for Postgres is RANDOM()
Navigation
[0] Message Index
Go to full version