Debugging Elgg SQL Queries

A little trick that I've learned for debugging a call to the Elgg API that involves a database call is to wrap it with $CONFIG->debug. For example:


$CONFIG->debug = true;
$images = get_entities('object', 'blog', $guid, '', 25);
$CONFIG->debug = false;


This will write the query to the error log giving you a chance to see what you are doing wrong (or if there is a bug in the Elgg framework). Make sure that the global $CONFIG is available within the context. This works fine with versions up to 1.6. Unknown how this will work on 1.7 and beyond.


Update: For Elgg 1.7 and above you need to do this:

$CONFIG->debug = 'NOTICE';
$images = get_entities('object', 'blog', $guid, '', 25);
unset($CONFIG->debug);

This assumes that you have debugging turned off. If you have it set to something else (like 'ERROR'), you should set it back to that setting.

Leave a comment

Recent Entries

  • Building a Web Services API with Elgg

    Elgg provides an API for building custom web services. You expose functionality through the web services API by building a plugin and then either publish...

  • Session security and Chrome Frame

    I've run into the nasty problem that Chrome Frame causes to session handling code that uses the user agent in its security. There are applications...

  • Piwik and Elgg

    While Google Analytics may be the most popular analytics service, there are times when you want to use your own hosted solution (intranet, control over...

  • Piwik and Reverse Proxy

    Piwik generates its URLs used in links and forms based on data in $_SERVER[]. If you are using a reverse proxy in front of your...

  • Elgg Unit Tests

    A new component in Elgg 1.7 will be a unit test framework (SimpleTest). I've written a skeleton example of how plugin authors can use the...

Close