Last active
January 26, 2021 13:44
-
-
Save avtehnik/ba72c7eea8394b77b2481b0bacd169c7 to your computer and use it in GitHub Desktop.
pdo log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PDOLog extends PDO{ | |
public $queriesLog = []; | |
public $transactionCounter = 0; | |
public function prepare(){ | |
$arg_list = func_get_args(); | |
$this->queriesLog[] = $arg_list[0]; | |
return call_user_func_array(array($this, 'parent::' . __FUNCTION__), $arg_list); | |
} | |
public function beginTransaction() | |
{ | |
$this->transactionCounter++; | |
return parent::beginTransaction(); | |
} | |
public function commit() | |
{ | |
$this->transactionCounter = 0; | |
return parent::commit(); | |
} | |
public function rollback() | |
{ | |
$this->transactionCounter = 0; | |
return parent::rollback(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$pdo = new PDOLog();
$pdo->queriesLog;
$pdo->pdotransactionCounter;