Flash or reset active codeigniter entries without execution after build?

In fact, I saw some suggestions in stackoverflow, but did not get an exact solution to this problem. Please do not think that this is a duplicate.

I use memcache for my codeigniter site and active records to build the request. I use

this->db->return_query_string(); 

to receive a request from active records before execution. Now I want to clear active records by running the same query.

also from various links

  $this->db->start_cache(); $this->db->stop_cache(); $this->db->flush_cache() 

can do the job, is this the exact result? if so, how can I get a cached request without executing

+4
source share
2 answers

You can use these two functions for your requirements.

 public function _compile_select($select_override = FALSE) public function _reset_select() 

To use them, you will have to delete public or private keywords.
Go to system / database / DB _active_rec.php Remove a public or protected keyword from these functions

Usage example

 $this->db->select('trans_id'); $this->db->from('myTable'); $this->db->where('code','B'); $subQuery = $this->db->_compile_select(); $this->db->_reset_select(); 

$ subQuery contains the query string, and _reset_select resets the active record so you can write a new query.

+5
source

Starting with CodeIgniter 3.x, you can do:

 $subQuery = $this->db ->select('trans_id') ->where('code', 'B') ->get_compiled_select('myTable'); 
+3
source

All Articles