• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using one where condition in two queries

I am having one query & one pagination query & I want to use only one where condition between two.Here is my code.


      $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.

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...

the CI solution for your problem are the AR cache functions.

thanks for the reply.....
i will try it in my queries....

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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