• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
model queries preference

#3
[eluser]CodeIgniteMe[/eluser]
Code:
// get all posts
function getPosts($table, $id = 'id', $limit = '100') {
  $q = $this->db->query("
   select *
   from ?
   order by ? desc
   limit ?
  ",array($table, $id, $limit));
  
  if($q->num_rows() > 0){
   return $q->result();
  }
} // end function

this method is only for query values, which is why it is automatically escaped as stated on the user guide
Queries

Brad's method is the recommended one for table and field names


Messages In This Thread
model queries preference - by El Forum - 06-20-2012, 08:34 AM
model queries preference - by El Forum - 06-20-2012, 09:25 AM
model queries preference - by El Forum - 06-21-2012, 02:20 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.