Part of the EllisLab Network
   
 
saving string query ? 
Posted: 11 May 2008 05:26 AM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  14
Joined  04-27-2007

hi

i use the active record class to build a query like this

$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

Profile
 
 
Posted: 11 May 2008 07:38 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  431
Joined  12-13-2007

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

$sql = $this->db->_compile_select();

 Signature 

PX Webdesign | The Lab | Personal Blog

Profile
 
 
Posted: 11 May 2008 07:50 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Avatar
Total Posts:  14
Joined  04-27-2007

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.

Profile
 
 
Posted: 11 May 2008 07:55 AM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1040
Joined  01-07-2008

So if I understand this properly you *could* also get the query string after you run the first get.  There you could use:

$this->db->last_query();

 Signature 

Blog | Twitter | Coffee

Profile
 
 
Posted: 11 May 2008 08:13 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Avatar
Total Posts:  14
Joined  04-27-2007

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

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 60651 Total Logged-in Users: 37
Total Topics: 73045 Total Anonymous Users: 3
Total Replies: 393857 Total Guests: 411
Total Posts: 466902    
Members ( View Memberlist )