[eluser]Unknown[/eluser]
Hi all,
I've hit a snag with Active Record trying to randomize data when doing a select:
Code:
$this->db->select('*');
$this->db->from('category_1');
$this->db->order_by('category_name', 'random');
$query = $this->db->get();
Generates the following statement (Which errors with mysql):
Code:
SELECT * FROM (`category_1`) ORDER BY `` RAND()
Code:
$this->db->order_by('', 'random');
gives the same error.
The only way I can get it to work is:
Code:
$this->db->order_by('RAND()')
But the manual doesn't explain it this way.
If I change line 854 in DB_active_rec.php from:
Code:
$orderby = ''; // Random results want or don't need a field name
To
Code:
$orderby = NULL; // Random results want or don't need a field name
It works as expected.
Thanks
Mark.