We help IT Professionals succeed at work.

bindValue override

tonelm54 asked
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?
Watch Question

Software Engineer
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:
As NetworkSoftware Engineer

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

Open in new window

thank you