Posted by Toby A Inkster on 02/20/07 15:46
Tonio wrote:
>> Maybe he wants to log it somewhere.
>
> That's it !
My only advice then would be to try extending PDO itself:
class MyPDO extends PDO
{
function query ($q)
{
try
{
return parent::query($q);
}
catch (PDOException $e)
{
$e->errorInfo[999] = $q;
throw $e;
}
}
function exec ($q)
{
try
{
return parent::exec($q);
}
catch (PDOException $e)
{
$e->errorInfo[999] = $q;
throw $e;
}
}
}
Then instead of using PDO, use MyPDO instead. When a PDOException is
thrown, you will now be able to inspect $e->errorInfo[999] to find the
cause of the error.
If you use prepared statements (and it is generally a good idea to do so!)
then you will also want to extend PDO->prepare() and PDOStatement->execute().
The only problem I forsee with that is a possible difficulty in cajoling
MyPDO->prepare() to return a MyPDOStatement object instead of a PDOStatement
object.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there!
Navigation:
[Reply to this message]
|