original_string: private function beginTransaction()
      {
          if (!$this->inTransaction) {
              if ('sqlite' === $this->driver) {
                  $this->pdo->exec('BEGIN IMMEDIATE TRANSACTION');
              } else {
                  if ('mysql' === $this->driver) {
                      $this->pdo->exec('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
                  }
                  $this->pdo->beginTransaction();
              }
              $this->inTransaction = true;
          }
      }
code: private function beginTransaction()
      {
          if (!$this->inTransaction) {
              if ('sqlite' === $this->driver) {
                  $this->pdo->exec('BEGIN IMMEDIATE TRANSACTION');
              } else {
                  if ('mysql' === $this->driver) {
                      $this->pdo->exec('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
                  }
                  $this->pdo->beginTransaction();
              }
              $this->inTransaction = true;
          }
      }
code_tokens: private function beginTransaction ( ) { if ( ! $ this -> inTransaction ) { if ( 'sqlite' === $ this -> driver ) { $ this -> pdo -> exec ( 'BEGIN IMMEDIATE TRANSACTION' ) ; } else { if ( 'mysql' === $ this -> driver ) { $ this -> pdo -> exec ( 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED' ) ; } $ this -> pdo -> beginTransaction ( ) ; } $ this -> inTransaction = true ; } }
docstring: Helper method to begin a transaction.
  
  Since SQLite does not support row level locks, we have to acquire a reserved lock
  on the database immediately. Because of https://bugs.php.net/42766 we have to create
  such a transaction manually which also means we cannot use PDO::commit or
  PDO::rollback or PDO::inTransaction for SQLite.
  
  Also MySQLs default isolation, REPEATABLE READ, causes deadlock for different sessions
  due to http://www.mysqlperformanceblog.com/2013/12/12/one-more-innodb-gap-lock-to-avoid/ .
  So we change it to READ COMMITTED.
docstring_tokens: Helper method to begin a transaction .