note 111824 deleted from mysqlinfo.api.choosing by googleguy
| From: | googleguy@php.net | Date: | Thu, 18 Feb 2016 01:05:08 +0000 |
| Subject: | note 111824 deleted from mysqlinfo.api.choosing by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-204970@lists.php.net to get a copy of this message | ||
Note Submitter: roland at mxchange dot org
----
To solve PDO limitations as described by michaeln at associations plus dot see eh, you may try to
overwrite PDO methods:
<?php
class MyPdo extends PDO {
// What ever parameters PDO wants + prepend some own:
public function query($caller, $line, $foo, $bar, $bazz) {
// Do your stuff here with $caller, $line (e.g. logging for debug purposes)
// Then call the extended method
return parent::QUERY($foo, $bar, $bazz) or $this->myErrorHandler($caller, $line, $someSqlToLog);
}
}
?>
This is only a very basic example. You may otherwise choose to "wrap" the PDO class and
save an instance of the "underlaying" PDO class inside the wrapper class. This is maybe a
little more complex approach but allows you to have on interfaces in class signature + way better
flexibility.