Skip to content

Commit

Permalink
Implement SQLite3Statement::errorCode() and errorInfo()
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Apr 25, 2015
1 parent 7fa223f commit a75f1b5
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions lib/Doctrine/DBAL/Driver/SQLite3/SQLite3Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SQLite3Statement extends SQLite3Abstract implements \IteratorAggregate, St
private $rowCount = 0;

/**
* The default fetch mode, one of the \PDO::FETCH_* constants.
* The default fetch mode, one of the PDO::FETCH_* constants.
*
* @var integer
*/
Expand All @@ -74,6 +74,20 @@ class SQLite3Statement extends SQLite3Abstract implements \IteratorAggregate, St
*/
private $fetchCtorArgs;

/**
* The error code for the last execution of the statement.
*
* @var integer
*/
private $lastErrorCode = 0;

/**
* The error message for the last execution of the statement.
*
* @var string
*/
private $lastErrorMessage = 'not an error';

/**
* Class constructor.
*
Expand Down Expand Up @@ -115,15 +129,19 @@ public function bindParam($column, & $variable, $type = null, $length = null)
*/
public function errorCode()
{
return '';
return $this->lastErrorCode;
}

/**
* {@inheritdoc}
*/
public function errorInfo()
{
return [];
return [
null,
$this->lastErrorCode,
$this->lastErrorMessage
];
}

/**
Expand All @@ -138,6 +156,10 @@ public function execute($params = null)
}

$result = @ $this->stmt->execute();

$this->lastErrorCode = $this->sqlite3->lastErrorCode();
$this->lastErrorMessage = $this->sqlite3->lastErrorMsg();

$this->throwExceptionOnError();

$this->result = $result;
Expand Down

0 comments on commit a75f1b5

Please sign in to comment.