Welcome Guest, Not a member yet? Register   Sign In
saving string query ?
#1

[eluser]quasiperfect[/eluser]
hi


i use the active record class to build a query like this
Code:
$this->db->select('id');
$this->db->where('tip','1');
$this->db->where('operatiune','0');

i want to save the query string to a var before doing the db get. is this possible ?

thanks in advance for any response
#2

[eluser]Lone[/eluser]
Interesting request - out of interest why are you needing to do this?

I had a quick look around the active record class and found you could grab it doing the following - cant comment on the reliablity of doing it this way as it isn't documented as it is just an internal function but does seems to work..

Code:
$sql = $this->db->_compile_select();
#3

[eluser]quasiperfect[/eluser]
thanks for the response i will try that
i'm doing this because i can get the query without the limit of the pagination part in a string
then run the query to see how many rows i have, set the number of rows in a session var
then run the query with limits to get the results so i don't have to do two separated procedures for this.
#4

[eluser]Pascal Kriete[/eluser]
So if I understand this properly you *could* also get the query string after you run the first get. There you could use:
Code:
$this->db->last_query();
#5

[eluser]quasiperfect[/eluser]
yes u'r right how could i miss that ... but the compile select function is usefull to know
i'm sure i will find a use for it Smile




Theme © iAndrew 2016 - Forum software by © MyBB