Why does PDO debugDumpParams crop a request

I found the same question here , but it went unanswered, and I provided a simpler example here and try again to ask ...

the code:

<?php
$dbh = new PDO('mysql:dbname=test;host=127.0.0.1', 'root');
$sth = $dbh->prepare("
    SELECT '
        Dumps the informations contained by a prepared statement directly on the output. It will provide the SQL query in use, the number of parameters used (Params), the list of parameters, with their name, type (paramtype) as an integer, their key name or position, and the position in the query (if this is supported by the PDO driver, otherwise, it will be -1).
        This is a debug function, which dump directly the data on the normal output.
        Tip:
        As with anything that outputs its result directly to the browser, the output-control functions can be used to capture the output of this function, and save it in a string (for example).
        This will only dumps the parameters in the statement at the moment of the dump. Extra parameters are not stored in the statement, and not displayed.
    '
");
$sth->execute();
$sth->debugDumpParams();

Result:

SQL: [835] 
    SELECT '
        Dumps the informations contained by a prepared statement directly on the output. It will provide the SQL query in use, the number of parameters used (Params), the list of parameters, with their name, type (paramtype) as an integer, their key name or position, and the position in the query (if this is supported by the PDO driver, otherwise, it will be -1).
        This is a debug function, which dump directly the data on the normal output.
        Tip:
        As with anythi
Params:  0

Why is this happening and how to fix it?
Thanks in advance!

+4
source share
2 answers

I think that debugDumpParamsis unreliable overall. The fact that it hides data right on the standard output!

Therefore, I would not use it in any case, and for logging purposes, enable general logging for mysql or create a wrapper around PDO with logging function (this solution is more portable).

+3

Why it occurs? - .
How fix it? - , , PDO.

- PHP ,
- to enable general log for mysql.

0

All Articles