Skip to content

Commit

Permalink
Merge pull request #3507 from morozov/error-code-info
Browse files Browse the repository at this point in the history
Removed errorCode() and errorInfo() methods from Connection and Statement APIs
  • Loading branch information
Ocramius authored and morozov committed Apr 16, 2019
2 parents 9f3c882 + 0f662c5 commit ba45fbd
Show file tree
Hide file tree
Showing 21 changed files with 9 additions and 357 deletions.
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Upgrade to 3.0

## BC BREAK `::errorCode()` and `::errorInfo()` removed from `Connection` and `Statement` APIs

The error information is available in `DriverException` trown in case of an error.

## BC BREAK Changes in driver exceptions

1. The `Doctrine\DBAL\Driver\DriverException::getErrorCode()` method is removed. In order to obtain the driver error code, please use `::getCode()`.
Expand Down
18 changes: 0 additions & 18 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1065,24 +1065,6 @@ public function getTransactionNestingLevel()
return $this->transactionNestingLevel;
}

/**
* Fetches the SQLSTATE associated with the last database operation.
*
* @return string|null The last error code.
*/
public function errorCode()
{
return $this->getWrappedConnection()->errorCode();
}

/**
* {@inheritDoc}
*/
public function errorInfo()
{
return $this->getWrappedConnection()->errorInfo();
}

/**
* Returns the ID of the last inserted row, or the last value from a sequence object,
* depending on the underlying driver.
Expand Down
14 changes: 0 additions & 14 deletions lib/Doctrine/DBAL/Driver/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,4 @@ public function commit() : void;
* @throws DriverException
*/
public function rollBack() : void;

/**
* Returns the error code associated with the last operation on the database handle.
*
* @return string|null The error code, or null if no operation has been run on the database handle.
*/
public function errorCode();

/**
* Returns extended error information associated with the last operation on the database handle.
*
* @return mixed[]
*/
public function errorInfo();
}
21 changes: 0 additions & 21 deletions lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
use const DB2_AUTOCOMMIT_ON;
use function db2_autocommit;
use function db2_commit;
use function db2_conn_error;
use function db2_conn_errormsg;
use function db2_connect;
use function db2_escape_string;
use function db2_exec;
Expand Down Expand Up @@ -165,23 +163,4 @@ public function rollBack() : void
throw DB2Exception::fromConnectionError($this->conn);
}
}

/**
* {@inheritdoc}
*/
public function errorCode()
{
return db2_conn_error($this->conn);
}

/**
* {@inheritdoc}
*/
public function errorInfo()
{
return [
0 => db2_conn_errormsg($this->conn),
1 => $this->errorCode(),
];
}
}
21 changes: 0 additions & 21 deletions lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
use function db2_free_result;
use function db2_num_fields;
use function db2_num_rows;
use function db2_stmt_error;
use function db2_stmt_errormsg;
use function error_get_last;
use function fclose;
use function fwrite;
Expand Down Expand Up @@ -165,25 +163,6 @@ public function columnCount()
return db2_num_fields($this->stmt) ?: 0;
}

/**
* {@inheritdoc}
*/
public function errorCode()
{
return db2_stmt_error();
}

/**
* {@inheritdoc}
*/
public function errorInfo()
{
return [
db2_stmt_errormsg(),
db2_stmt_error(),
];
}

/**
* {@inheritdoc}
*/
Expand Down
16 changes: 0 additions & 16 deletions lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,6 @@ public function rollBack() : void
}
}

/**
* {@inheritdoc}
*/
public function errorCode()
{
return $this->conn->errno;
}

/**
* {@inheritdoc}
*/
public function errorInfo()
{
return $this->conn->error;
}

/**
* Apply the driver options to the connection.
*
Expand Down
16 changes: 0 additions & 16 deletions lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,22 +388,6 @@ public function fetchColumn($columnIndex = 0)
return $row[$columnIndex];
}

/**
* {@inheritdoc}
*/
public function errorCode()
{
return $this->_stmt->errno;
}

/**
* {@inheritdoc}
*/
public function errorInfo()
{
return $this->_stmt->error;
}

/**
* {@inheritdoc}
*/
Expand Down
27 changes: 0 additions & 27 deletions lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,31 +199,4 @@ public function rollBack() : void

$this->executeMode = OCI_COMMIT_ON_SUCCESS;
}

/**
* {@inheritdoc}
*/
public function errorCode()
{
$error = oci_error($this->dbh);
if ($error !== false) {
$error = $error['code'];
}

return $error;
}

/**
* {@inheritdoc}
*/
public function errorInfo()
{
$error = oci_error($this->dbh);

if ($error === false) {
return [];
}

return $error;
}
}
27 changes: 0 additions & 27 deletions lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,33 +342,6 @@ public function columnCount()
return oci_num_fields($this->_sth) ?: 0;
}

/**
* {@inheritdoc}
*/
public function errorCode()
{
$error = oci_error($this->_sth);
if ($error !== false) {
$error = $error['code'];
}

return $error;
}

/**
* {@inheritdoc}
*/
public function errorInfo()
{
$error = oci_error($this->_sth);

if ($error === false) {
return [];
}

return $error;
}

/**
* {@inheritdoc}
*/
Expand Down
16 changes: 0 additions & 16 deletions lib/Doctrine/DBAL/Driver/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,6 @@ public function rollBack() : void
$this->connection->rollBack();
}

/**
* {@inheritDoc}
*/
public function errorCode()
{
return $this->connection->errorCode();
}

/**
* {@inheritDoc}
*/
public function errorInfo()
{
return $this->connection->errorInfo();
}

public function getWrappedConnection() : PDO
{
return $this->connection;
Expand Down
16 changes: 0 additions & 16 deletions lib/Doctrine/DBAL/Driver/PDOStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,6 @@ public function columnCount()
return $this->stmt->columnCount();
}

/**
* {@inheritdoc}
*/
public function errorCode()
{
return $this->stmt->errorCode();
}

/**
* {@inheritdoc}
*/
public function errorInfo()
{
return $this->stmt->errorInfo();
}

/**
* {@inheritdoc}
*/
Expand Down
18 changes: 0 additions & 18 deletions lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
use function sasql_affected_rows;
use function sasql_commit;
use function sasql_connect;
use function sasql_error;
use function sasql_errorcode;
use function sasql_escape_string;
use function sasql_insert_id;
use function sasql_pconnect;
Expand Down Expand Up @@ -84,22 +82,6 @@ public function commit() : void
$this->endTransaction();
}

/**
* {@inheritdoc}
*/
public function errorCode()
{
return sasql_errorcode($this->connection);
}

/**
* {@inheritdoc}
*/
public function errorInfo()
{
return sasql_error($this->connection);
}

/**
* {@inheritdoc}
*/
Expand Down
18 changes: 0 additions & 18 deletions lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
use function sasql_prepare;
use function sasql_stmt_affected_rows;
use function sasql_stmt_bind_param_ex;
use function sasql_stmt_errno;
use function sasql_stmt_error;
use function sasql_stmt_execute;
use function sasql_stmt_field_count;
use function sasql_stmt_reset;
Expand Down Expand Up @@ -144,22 +142,6 @@ public function columnCount()
return sasql_stmt_field_count($this->stmt);
}

/**
* {@inheritdoc}
*/
public function errorCode()
{
return sasql_stmt_errno($this->stmt);
}

/**
* {@inheritdoc}
*/
public function errorInfo()
{
return sasql_stmt_error($this->stmt);
}

/**
* {@inheritdoc}
*
Expand Down
23 changes: 0 additions & 23 deletions lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement as DriverStatement;
use const SQLSRV_ERR_ERRORS;
use function sqlsrv_begin_transaction;
use function sqlsrv_commit;
use function sqlsrv_configure;
use function sqlsrv_connect;
use function sqlsrv_errors;
use function sqlsrv_query;
use function sqlsrv_rollback;
use function sqlsrv_rows_affected;
Expand Down Expand Up @@ -162,25 +160,4 @@ public function rollBack() : void
throw SQLSrvException::fromSqlSrvErrors();
}
}

/**
* {@inheritDoc}
*/
public function errorCode()
{
$errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
if ($errors) {
return $errors[0]['code'];
}

return false;
}

/**
* {@inheritDoc}
*/
public function errorInfo()
{
return (array) sqlsrv_errors(SQLSRV_ERR_ERRORS);
}
}
Loading

0 comments on commit ba45fbd

Please sign in to comment.