Sql Query Lookup

Hi,



I've got a question, is it possible and if so, how could I check what SQL Query is being done after an certain action done in the backend?



eg. Im using some advanced search filters and want to see what SQL Query is sent after I press “Search”

Version 2.1 btw.

Anyone?

Your request is not quite clear. Please provide us with more details and examples

I have a problem with my shop after switching to cloud hosting. Whenever you use advanced search in Cs-cart panel (eg. choosing only active products, typing product code etc.) none of the parameters apply. So providing we have 500 active products, 250 inactive, and 250 hidden, when you make a search for only active ones, the result is still 1000 products (all of them).

Hence, I wanted to check what is the SQL Query that is being done after clicking the “Search” button.

Thank you for the clarification. May be default debugger will help you:



http://docs.cs-cart.com/4.2.x/tools/debugger.html?highlight=debug

Only its for v.4+ and we are running 2.1 :(

[quote name=‘Fedor’ timestamp=‘1408371056’ post=‘189849’]

Only its for v.4+ and we are running 2.1 :(

[/quote]



For 2.x versions you can open the config.php file and uncomment the following lines:


<br />
// define('PROFILER', true);<br />
// define('PROFILER_SQL', true);<br />
// define('PROFILER_FOR_ADMIN', true);<br />

```<br />
<br />
Then clear cache and log in the store-front under admin to see debug information

Thanks, it worked, althought the amount of SQL queries shown in this one action is enormous

That's why caching is so important and why having a properly configured mySQL is so important. Every page view puts a big load on the server. It is the nature of cs-cart. It is far from “light weight”.

Is there a way to display errors, if there are any, while those queries are being processed?

Everything seems to be in order, but after migration to cloud hosting the advanced search in backend doesn't work. None of the parameters apply. Any suggestions what may be the cause? Am I missing some server config settings?

I mean php errors, because the SQL Queries are, at least in my view, correct

[quote name='Fedor' timestamp='1408960887' post='190560']

I mean php errors, because the SQL Queries are, at least in my view, correct

[/quote]



You need to enable it via the php configuration. It is disabled by default. If you have any errors, this will create a file in the root ie. /public_html/error_log

error_log = error_log
log_errors = 1

[quote name=‘The Tool’ timestamp=‘1408961917’ post=‘190563’]

You need to enable it via the php configuration. It is disabled by default. If you have any errors, this will create a file in the root ie. /public_html/error_log

error_log = error_log<br />
log_errors = 1
```<br />
[/quote]<br />
<br />
Thanks, I did it, no file was even created during the operation of advanced search <img src="upload://n4syhXZrRhsStKvmS4jT3Mp2S3k.png" class="bbc_emoticon" alt=":(">

Temporarily, create a file in the root of your store named 'local.conf.php'. It should have the following content:

```php

if( !defined('BOOTSTRAP') ) die('Access denied');
if( $_SERVER['REQUEST_METHOD'] != 'POST' && !defined('AJAX_REQUEST') ) {
if( !defined('DEVELOPMENT') ) define('DEVELOPMENT', true);
error_reporting(E_ALL);
ini_set('display_errors', true);
}
```

Run whatever and it will display any php errors to the screen. Note that if the errors happen in the POST part of the transaction that they will not be shown.

To find where your site is configured to place the PHP error_log file you can do a phpinfo() or from a command line do:
php -i | grep error_log

Remove the local.conf.php file when you're done or make it conditional upon AREA == 'A'.

Thanks for answer, however, adding the code in local.conf.php (which already exists) makes the backend go all “access denied” on me :)



php -i | grep error_log on the other hand says “error_log => no value => no value”

Need to talk to your developer if it already exists. If it generates a lot of messages then that is probably the source of your issues. Hiding Notices and Warnings is not usually a correct solution.

Upon further investigation, when I make an extended search the URL stays at “type=simple” and naturally none of the params in the advanced search field gets up there. Why does the search type stays simple if it is not?


// Set default values to input params
$default_params = array (
'pname' => '',
'pshort' => '',
'pfull' => '',
'pkeywords' => '',
'feature' => array(),
'type' => 'simple',
...

...
// Extended search mode condition for SQL query
if ($params['type'] == 'extended') {




Something need to be changed here? (fn.catalog.php)

Any ideas? No change has been made to application. It works on the old server, it doesnt work (broken advanced search) on new server with IDENTICAL config (as claimed by the hosting company, which is probably rubbish, but lets assume so)

[quote name='Fedor' timestamp='1409580966' post='191217']

Any ideas? No change has been made to application. It works on the old server, it doesnt work (broken advanced search) on new server with IDENTICAL config (as claimed by the hosting company, which is probably rubbish, but lets assume so)

[/quote]



Additional examination is required. Our specialists can check the issue. If you are interested, please contact me