Welcome Guest, Not a member yet? Register   Sign In
partial active records query inside a method
#1

[eluser]keevitaja[/eluser]
hi,

what is the best way to achieve following:

i need to run several where() and like() in active records before fetching them in more than one place. these where and like are allways same. what changes are the get() and result() type.

something like that:

Code:
class Myclass
{
function filters()
{
  if (something)
  {
   $this->db->where('something')
  }
  
  if (something)
  {
   $this->db->like('something')
  }
  
  if (something)
  {
   $this->db->like('something')
  }
  
  if (something)
  {
   $this->db->where('something')
  }
  
  return $this->db
}
}

$myclass->filters()->get('mytable')->result()
$myclass->filters()->where('somethign')->get('mytable')->result_array()


Messages In This Thread
partial active records query inside a method - by El Forum - 07-10-2013, 12:38 PM
partial active records query inside a method - by El Forum - 07-18-2013, 04:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB