Created
October 12, 2011 12:44
-
-
Save m4rcsch/1281141 to your computer and use it in GitHub Desktop.
Simple li3 sql statement exporter using var_dump
This file contains 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
/** | |
* General info: | |
* Embed this code in your lithium (li3) app. | |
* At the end of the app\config\connections.php for example. | |
* | |
* Uncomment the var_dump lines OR use the lithium Logger Class | |
* Use/modify the first callback, if you just want to see the query array data. | |
* Use the second callback for dumping the raw sql data. | |
* | |
* @author: 2011 weluse GmbH, Marc Schwering | |
*/ | |
Connections::get("default")->applyFilter("read", function($self, $params, $chain) { | |
$response = $chain->next($self, $params, $chain); | |
if (is_a($params['query'], 'lithium\data\model\Query')) { | |
/** | |
* dump the query-object-data as array: | |
*/ | |
//var_dump($params['query']->export($self)); | |
/** | |
* dump the result: | |
*/ | |
//var_dump($res->data()); | |
} // | |
return $response; | |
}); | |
Connections::get('default')->applyFilter("_execute", function($self, $params, $chain) { | |
$response = $chain->next($self, $params, $chain); | |
/** | |
* dump the raw sql query: | |
*/ | |
//var_dump($params['sql']); | |
return $response; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment