• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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....


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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