P. 1
Random Query

Random Query

|Views: 1|Likes:
Published by Made Maldino

More info:

Published by: Made Maldino on Dec 28, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

12/28/2010

pdf

text

original

random model query : // Inside of Controller Class function _getReal($id,$name_of_table) { $Q=$this->db->where('id',$id)->get

($name_of_table); if($Q->num_rows()>0){return $Q;}else{return FALSE;} } function _getLastRecord($name_of_table) { $Q=$this->db->select("id")->order_by('id DESC')->limit("1")->get($name_of_table )->row_array(); return $Q['id']; } function getrandom() { $name_of_table="news"; $id=rand(1,$this->_getLastRecord($name_of_table)); if($this->_getReal($id,$name_of_table)!==FALSE) { echo $id; // Here goes your code } else { $this->getrandom(); } // END

another : function get_random_page() { $this->db->order_by('id', 'RANDOM'); $this->db->limit(1); $query = $this->db->get('pages'); return $query->result_array(); }

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->