I'm using PDO
with the sqlsrv
drivers. I would like to print out all queries passed through the connection that's initalised in __construct
.
My setup is as followed;
public function __construct() {
try{
$this->connRead = new PDO( "sqlsrv:server=" . DB_SERVER . "; Database =" . DB_NAME, DB_USER_READ, DB_PASSWORD_READ);
$this->connRead->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e){ echo 'Connection failed: ' . $e->getMessage(); }
}
public function __destruct() { $this->connRead = null; $this->connWrite= null; }
I would then make a request/call as such;
$sSQL = "SELECT foo FROM Table"
$st = $this->connRead->prepare( $sSQL );
$st->execute();
On loading a page I would like to be able to print all queries that use $this->connRead
in plain text to the browser. Is it possible to do this?