bindValue override

tonelm54
tonelm54 used Ask the Experts™
on
Im trying to debug several SQL statments, and thinking a way around is to override the 'bindValue' method so I can log what is being bound to the query. So what I currently do is:-
$rsRowImport = $this->pdo->prepare($this->JSONRec['SQL']);
$rsRowImport->bindValue(':field`, 'Test'l,PDO::PARAM_STR);

Open in new window


So, what I want to do is override the return of prepare to $rwRowImport, and then override the bindValue so I can add in a logging method, then I can call the parent bindValue to do the actual bindValue.

My issue is, I have no idea how i can capture what is returned and then override it. Any ideas?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Engineer
Commented:
There is a debug method provided by the PDO extension.

See the examples on the manual page, they seem to be exactly what you're looking for:
http://php.net/manual/en/pdostatement.debugdumpparams.php
As NetworkSoftware Engineer

Commented:
Please use this code:
$rsRowImport = $this->pdo->prepare($this->JSONRec['SQL']);
$rsRowImport->bindValue(':field', 'Testl', PDO::PARAM_STR);

Open in new window


thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial