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()
#2

[eluser]plain jane[/eluser]
A switch case would help in this case.




Theme © iAndrew 2016 - Forum software by © MyBB