Welcome Guest, Not a member yet? Register   Sign In
Using one where condition in two queries
#1

[eluser]Computerzworld[/eluser]
Hello,
I am having one query & one pagination query & I want to use only one where condition between two.Here is my code.

Code:
$this->db->where('isDeleted',0);

if($this->paginate==TRUE)
{
      $this->total = $this->db->count_all_results("mytable");
      $this->numpages = ceil($this->total / $this->limit);
            
      $offset = ($this->page * $this->limit) - $this->limit;
      $this->db->limit($this->limit, $offset);
}
        
$query = $this->db->get("mytable");

But this where conditon applies to only $this->db->count_all_results() condition & not $this->db->get(). Is it possible to use that in common between these two? If yes then how? Please help me. Thanks in advance.
#2

[eluser]Computerzworld[/eluser]
got the solution Smile....
what I did is created one function in model itself & put all the where conditions in it & called that function before getting paging result & query result....

And that worked...
HTH.....
#3

[eluser]xwero[/eluser]
the CI solution for your problem are the AR cache functions.
#4

[eluser]Computerzworld[/eluser]
thanks for the reply.....
i will try it in my queries....




Theme © iAndrew 2016 - Forum software by © MyBB