Skip to content

Instantly share code, notes, and snippets.

@avtehnik
Last active January 26, 2021 13:44
Show Gist options
  • Select an option

  • Save avtehnik/ba72c7eea8394b77b2481b0bacd169c7 to your computer and use it in GitHub Desktop.

Select an option

Save avtehnik/ba72c7eea8394b77b2481b0bacd169c7 to your computer and use it in GitHub Desktop.

Revisions

  1. avtehnik revised this gist Jan 26, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions pdolog.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    <?php

    class PDOLog extends PDO{

    public $queriesLog = [];
  2. avtehnik created this gist Jan 26, 2021.
    31 changes: 31 additions & 0 deletions pdolog.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    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();
    }
    }