News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Brian Moon's Blog:
PHP/MySQL Debug Trick
August 29, 2006 @ 07:28:56

Brian Moon has had his share of issues with connecting PHP to MySQL, but sometimes, it's harder to track down the problem than others. So, he decided to put a simple trick in place to help him (and the mysqladmin proc command) locate the offending query.

We use a class that I wrote for all of our access to mysql. Its basically a wrapper for mysql_connect, mysql_select_db, mysql_query, mysql_num_rows(), etc. One method to handle all of that. Lots of you probably have one of these objects or libraries. Anyhow, what I did was add a comment into the sql just before I run the query.

Now, mysqladmin proc has the request URI for every query in it. The MySQL slow query log does as well. I know this is a simple little thing, but man, is it useful.

This trick is a quick and easy way to help see what page it is that's causing the issue (since multiple pages can use one SQL call), but it can also be used to help track down other values effecting the SQL as well. Very handy.

3 comments voice your opinion now!
mysql debug trick sql query comment request_uri mysql debug trick sql query comment request_uri


blog comments powered by Disqus

Similar Posts

PHPClasses.org: Lately in PHP, Episode 31 - The Urge to Kill Older PHP Versions

Gennady Feldman's Blog: Oracle query validation

AskAboutPHP.com: Codeigniter: Mixing segment-based URL with querystrings

Vexxhost.com: Top 5 new (and cool!) features in PHP5 that you probably haven't heard of

CodePoets.co.uk: A Quickstart to using PEAR with PHP


Community Events

Don't see your event here?
Let us know!


laravel laravel5 library extension wordpress community api development conference release middleware podcast opinion voicesoftheelephpant framework series introduction language unittest interview

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework