Created
February 19, 2013 08:42
-
-
Save janich/4984102 to your computer and use it in GitHub Desktop.
Ugly, but helpfull!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function q($query) { | |
echo "<pre>"; | |
$q = str_replace("#__", JFactory::getConfig()->get('dbprefix'), (string) $query); | |
var_dump($q); | |
echo "</pre>"; | |
} |
If you don't mind the prefix remaining, I always just echo (string) $query;
I guess it wasn't really about the method, but about having an easy way to echo out a query with the correct prefixes while developing.
Heh, yeah, it probably is bit overkill. Larger/complex queries should probably be kept in a SQL editor until 'ready' ;)
It's still on my TODO to check out the Joomla extension J!Dump, so I can't say how handy it is, but it looks promising:
http://extensions.joomla.org/extensions/miscellaneous/development/1509
I also use var_dump. If you view the source you don't need to add the pre tags, but the pre tags are indeed necessarily if you want to view it in readable html format.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't reinvent the wheel, Janich:
function q($query) {
";$db = JFactory::getDbo();
echo "
}
You can also use JLog instead of var_dump (neater) or turn on Debug System (it logs all queries going through JDatabaseDriver, additionally showing them in the debug module).