debug SQL Statement w. PHP lib
debug SQL Statement w. PHP lib
Hello,
iam trying to debug a SQL statement, when i use the PHP libs from DT Editor.
The debug function works fine, when is use the Editor Class. But sometimes is need the Database/Query Class.
https://editor.datatables.net/docs/1.7.3/php/class-DataTables.Database.html#_debug
$data = $mydb
->query( 'select' )
->table( 'important_table' )
->get( array( "important_column" ) )
->where ( "id", 5, "=" )
->exec()->fetchAll();
When i add ->debug(true) before ->query (like the "Editor" way)
Fatal error: Function name must be a string in [...]/libs/datatables/php/Database/Database.php on line 422
It won't work with debugInfo() too. I don't know how to receive the information.
Thanks alot in advance.
Replies
The
Database
class also hasdebug()
methods available. Try:Note that
debugInfo
isn't documented there - its an internal function that I didn't really expect to be used externally, but it is public.Allan
Thanks for the reply. I forgot to mention, that i use oracle as db.
When i try your example it also tells me:
So when you set ->debug(true), the internal variable ->_debugCallback will be set to true. When you call ->debugInfo() a callback function named "true"(from ->_debugCallback) fails.
PHP debug:
PHP debugInfo:
If you try a string instead of bool(true) in ->debug('veryImportantString') it says:
Can you show me the code you are using please?
Allan
I've created this simple example, which leads to the error. Iam using version 1.7.3.
Sorry - I forgot I refactored that bit not long ago!
Use this:
Then all the debug statements will be written to
$debug
.Allan
Ok that's the solution i was looking for. Thank you very much, great help as always.
Here is a working example:
With this output: