Zen Cart Logo
Forums / Code Collaboration / display full query

display full query

Views: 2,380

Results 1 to 5 of 5
11 Jul 2014, 2:27 PM
#1
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

display full query

This has always been a problem for me and I don't know how folks deal with queries when they can't see the structure. I need evidence of what the query looks like so I can troubleshoot it. (yeah, well, so maybe I'm not a natural born php coder - I learned everything I know from zen cart itself!)

So how in the world do I get a query to display? I have some php functions that I use outside zen cart but was hoping there would be an easier way than recreating that with zen cart functions.

11 Jul 2014, 3:09 PM
#2
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: display full query

I typically apply a variation of lat9's Use debug_backtrace in query_factory to aid in tracing down the source of misbehaving SQL Queries.

I typically install a variation of Query Log by data-diggers if I want to see every SQL query made by a specific Zen Cart page (requires Query Cache - Zen Cart 1.5.1+ includes a version of Query Cache). I do not typically install this on a production site, only development sites as needed.

11 Jul 2014, 5:09 PM
#3
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: display full query

Thanks for replying. According to my research some or all of that has been included in 1.5.2, 1.5.3.

I did realize I can turn on the query log and that helps some but can't find the query I'm looking for.

I need to be able to see the search query on the advanced search page.

I'm trying to add in another table to the search function and can't see what I'm missing.

11 Jul 2014, 5:22 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: display full query

Very low-tech, but if you know where (in what file) the query is executed (like $db->Execute($query_string) ), you can follow that with an echo of whatever variable is being executed.

11 Jul 2014, 5:36 PM
#5
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: display full query

Yes some "Query Log" components are now included, but Zen Cart 1.5.2 and 1.5.3 do not include all portions of the original data-diggers code. In particular it does not include the QueryLog class, QueryLog autoloader, or "performance" function file. These will log every SQL Query going through "Query Cache" in MEMORY (along with details). You can then display the list of SQL Queries run by each page by adding a snippet of code to the header, footer, or main page the of your Zen Cart template to display the SQL Queries.

I would not recommend simply "overwriting" the current Zen Cart files with any from the original "Query Log" (for Zen Cart 1.3.x). But one can grab the three files mentioned above (and add the snippet to the current template). I would also not recommend installing the changes on a production site.

Otherwise gjh42's "low-tech" option works well.