[eluser]ommy[/eluser]
There was a reason indeed. I was checking the your reply from a mobile device and didnt have the files on that device.
Here's the actual copy-pasted code.
Code:
$this->db->order_by('id','random');
$this->db->limit(1);
$row = $this->db->get_where('gallery',array('active' => 1, 'public'=> 1))->row();
I messed around with situations a bit more and it seems that the following ways do work:
Code:
$random_row = mysql_fetch_row(mysql_query("select * from gallery order by rand() limit 1"));
$random_row = $this->db->query('select * from gallery order by rand() limit 1')->row();
i thought it was solved with this, but turned out to ignore the rand():
Code:
$this->db->order_by('id','rand()');
$random_row = $this->db->get_where('gallery',array('active' => 1, 'public'=> 1))->row();
and finally i just tried regular old mysql, which worked perfectly:
Code:
$row = $this->db->query('select * from gallery where active=1 and public=1 order by rand() limit 1')->row();
could the backtick you're talking about be a typo in the constant for random?
I'm probably on the wrong track with this. Just trying to figure out what it is i missed.
Doesn't seem like too hard of an operation.
Thanks for the reply. I'll remind myself never to be sure about syntax