diff options
author | Andrey Andreev <narf@devilix.net> | 2014-05-09 09:24:14 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-05-09 09:24:14 +0200 |
commit | 2bbbd1a13ead097fd3f4b00bfb275f0b0f836f93 (patch) | |
tree | 9a1615f486dac1502c024d8fcd57e066a875b4a2 /system | |
parent | 81b6efa76b90e28c87d1efad50dc13c2ac462ca8 (diff) |
Remove (most of) error suppression from database drivers (issue #3036)
Diffstat (limited to 'system')
-rw-r--r-- | system/database/drivers/cubrid/cubrid_driver.php | 8 | ||||
-rw-r--r-- | system/database/drivers/cubrid/cubrid_result.php | 4 | ||||
-rw-r--r-- | system/database/drivers/ibase/ibase_driver.php | 12 | ||||
-rw-r--r-- | system/database/drivers/ibase/ibase_result.php | 8 | ||||
-rw-r--r-- | system/database/drivers/mssql/mssql_driver.php | 10 | ||||
-rw-r--r-- | system/database/drivers/mssql/mssql_result.php | 6 | ||||
-rw-r--r-- | system/database/drivers/mysql/mysql_driver.php | 15 | ||||
-rw-r--r-- | system/database/drivers/mysql/mysql_result.php | 6 | ||||
-rw-r--r-- | system/database/drivers/oci8/oci8_driver.php | 6 | ||||
-rw-r--r-- | system/database/drivers/oci8/oci8_result.php | 4 | ||||
-rw-r--r-- | system/database/drivers/odbc/odbc_driver.php | 6 | ||||
-rw-r--r-- | system/database/drivers/odbc/odbc_result.php | 4 | ||||
-rw-r--r-- | system/database/drivers/pdo/pdo_result.php | 2 | ||||
-rw-r--r-- | system/database/drivers/postgre/postgre_driver.php | 12 | ||||
-rw-r--r-- | system/database/drivers/postgre/postgre_result.php | 4 | ||||
-rw-r--r-- | system/database/drivers/sqlite/sqlite_driver.php | 8 | ||||
-rw-r--r-- | system/database/drivers/sqlsrv/sqlsrv_driver.php | 2 |
17 files changed, 61 insertions, 56 deletions
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 2e79faa39..138b0ed45 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -172,7 +172,7 @@ class CI_DB_cubrid_driver extends CI_DB { */ protected function _execute($sql) { - return @cubrid_query($sql, $this->conn_id); + return cubrid_query($sql, $this->conn_id); } // -------------------------------------------------------------------- @@ -283,7 +283,7 @@ class CI_DB_cubrid_driver extends CI_DB { */ public function affected_rows() { - return @cubrid_affected_rows(); + return cubrid_affected_rows(); } // -------------------------------------------------------------------- @@ -295,7 +295,7 @@ class CI_DB_cubrid_driver extends CI_DB { */ public function insert_id() { - return @cubrid_insert_id($this->conn_id); + return cubrid_insert_id($this->conn_id); } // -------------------------------------------------------------------- @@ -418,7 +418,7 @@ class CI_DB_cubrid_driver extends CI_DB { */ protected function _close() { - @cubrid_close($this->conn_id); + cubrid_close($this->conn_id); } } diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php index 76a479a18..d2bdeb0f5 100644 --- a/system/database/drivers/cubrid/cubrid_result.php +++ b/system/database/drivers/cubrid/cubrid_result.php @@ -47,7 +47,7 @@ class CI_DB_cubrid_result extends CI_DB_result { { return is_int($this->num_rows) ? $this->num_rows - : $this->num_rows = @cubrid_num_rows($this->result_id); + : $this->num_rows = cubrid_num_rows($this->result_id); } // -------------------------------------------------------------------- @@ -59,7 +59,7 @@ class CI_DB_cubrid_result extends CI_DB_result { */ public function num_fields() { - return @cubrid_num_fields($this->result_id); + return cubrid_num_fields($this->result_id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/ibase/ibase_driver.php b/system/database/drivers/ibase/ibase_driver.php index b9eabd00e..b19985c37 100644 --- a/system/database/drivers/ibase/ibase_driver.php +++ b/system/database/drivers/ibase/ibase_driver.php @@ -115,7 +115,7 @@ class CI_DB_ibase_driver extends CI_DB { */ protected function _execute($sql) { - return @ibase_query($this->conn_id, $sql); + return ibase_query($this->conn_id, $sql); } // -------------------------------------------------------------------- @@ -139,7 +139,7 @@ class CI_DB_ibase_driver extends CI_DB { // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE); - $this->_ibase_trans = @ibase_trans($this->conn_id); + $this->_ibase_trans = ibase_trans($this->conn_id); return TRUE; } @@ -159,7 +159,7 @@ class CI_DB_ibase_driver extends CI_DB { return TRUE; } - return @ibase_commit($this->_ibase_trans); + return ibase_commit($this->_ibase_trans); } // -------------------------------------------------------------------- @@ -177,7 +177,7 @@ class CI_DB_ibase_driver extends CI_DB { return TRUE; } - return @ibase_rollback($this->_ibase_trans); + return ibase_rollback($this->_ibase_trans); } // -------------------------------------------------------------------- @@ -189,7 +189,7 @@ class CI_DB_ibase_driver extends CI_DB { */ public function affected_rows() { - return @ibase_affected_rows($this->conn_id); + return ibase_affected_rows($this->conn_id); } // -------------------------------------------------------------------- @@ -392,7 +392,7 @@ class CI_DB_ibase_driver extends CI_DB { */ protected function _close() { - @ibase_close($this->conn_id); + ibase_close($this->conn_id); } } diff --git a/system/database/drivers/ibase/ibase_result.php b/system/database/drivers/ibase/ibase_result.php index 1f89db65d..cb2c7f4a6 100644 --- a/system/database/drivers/ibase/ibase_result.php +++ b/system/database/drivers/ibase/ibase_result.php @@ -45,7 +45,7 @@ class CI_DB_ibase_result extends CI_DB_result { */ public function num_fields() { - return @ibase_num_fields($this->result_id); + return ibase_num_fields($this->result_id); } // -------------------------------------------------------------------- @@ -103,7 +103,7 @@ class CI_DB_ibase_result extends CI_DB_result { */ public function free_result() { - @ibase_free_result($this->result_id); + ibase_free_result($this->result_id); } // -------------------------------------------------------------------- @@ -117,7 +117,7 @@ class CI_DB_ibase_result extends CI_DB_result { */ protected function _fetch_assoc() { - return @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS); + return ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS); } // -------------------------------------------------------------------- @@ -132,7 +132,7 @@ class CI_DB_ibase_result extends CI_DB_result { */ protected function _fetch_object($class_name = 'stdClass') { - $row = @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS); + $row = ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS); if ($class_name === 'stdClass' OR ! $row) { diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index afe80e8d9..f4a166180 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -142,9 +142,9 @@ class CI_DB_mssql_driver extends CI_DB { $database = $this->database; } - // Note: The brackets are required in the event that the DB name + // Note: Escaping is required in the event that the DB name // contains reserved characters - if (@mssql_select_db($this->escape_identifiers($database), $this->conn_id)) + if (mssql_select_db($this->escape_identifiers($database), $this->conn_id)) { $this->database = $database; return TRUE; @@ -163,7 +163,7 @@ class CI_DB_mssql_driver extends CI_DB { */ protected function _execute($sql) { - return @mssql_query($sql, $this->conn_id); + return mssql_query($sql, $this->conn_id); } // -------------------------------------------------------------------- @@ -235,7 +235,7 @@ class CI_DB_mssql_driver extends CI_DB { */ public function affected_rows() { - return @mssql_rows_affected($this->conn_id); + return mssql_rows_affected($this->conn_id); } // -------------------------------------------------------------------- @@ -519,7 +519,7 @@ class CI_DB_mssql_driver extends CI_DB { */ protected function _close() { - @mssql_close($this->conn_id); + mssql_close($this->conn_id); } } diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php index cce93740f..f3ee987ed 100644 --- a/system/database/drivers/mssql/mssql_result.php +++ b/system/database/drivers/mssql/mssql_result.php @@ -47,7 +47,7 @@ class CI_DB_mssql_result extends CI_DB_result { { return is_int($this->num_rows) ? $this->num_rows - : $this->num_rows = @mssql_num_rows($this->result_id); + : $this->num_rows = mssql_num_rows($this->result_id); } // -------------------------------------------------------------------- @@ -59,7 +59,7 @@ class CI_DB_mssql_result extends CI_DB_result { */ public function num_fields() { - return @mssql_num_fields($this->result_id); + return mssql_num_fields($this->result_id); } // -------------------------------------------------------------------- @@ -167,7 +167,7 @@ class CI_DB_mssql_result extends CI_DB_result { */ protected function _fetch_object($class_name = 'stdClass') { - $row = @mssql_fetch_object($this->result_id); + $row = mssql_fetch_object($this->result_id); if ($class_name === 'stdClass' OR ! $row) { diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 9fbd94ce8..7cbcf1028 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -119,6 +119,7 @@ class CI_DB_mysql_driver extends CI_DB { $client_flags = $client_flags | MYSQL_CLIENT_SSL; } + // Error suppression is necessary mostly due to PHP 5.5+ issuing E_DEPRECATED messages $this->conn_id = ($persistent === TRUE) ? @mysql_pconnect($this->hostname, $this->username, $this->password, $client_flags) : @mysql_connect($this->hostname, $this->username, $this->password, TRUE, $client_flags); @@ -176,7 +177,7 @@ class CI_DB_mysql_driver extends CI_DB { $database = $this->database; } - if (@mysql_select_db($database, $this->conn_id)) + if (mysql_select_db($database, $this->conn_id)) { $this->database = $database; return TRUE; @@ -195,7 +196,7 @@ class CI_DB_mysql_driver extends CI_DB { */ protected function _db_set_charset($charset) { - return @mysql_set_charset($charset, $this->conn_id); + return mysql_set_charset($charset, $this->conn_id); } // -------------------------------------------------------------------- @@ -216,7 +217,7 @@ class CI_DB_mysql_driver extends CI_DB { $this->initialize(); } - if ( ! $this->conn_id OR ($version = @mysql_get_server_info($this->conn_id)) === FALSE) + if ( ! $this->conn_id OR ($version = mysql_get_server_info($this->conn_id)) === FALSE) { return FALSE; } @@ -234,7 +235,7 @@ class CI_DB_mysql_driver extends CI_DB { */ protected function _execute($sql) { - return @mysql_query($this->_prep_query($sql), $this->conn_id); + return mysql_query($this->_prep_query($sql), $this->conn_id); } // -------------------------------------------------------------------- @@ -349,7 +350,7 @@ class CI_DB_mysql_driver extends CI_DB { */ public function affected_rows() { - return @mysql_affected_rows($this->conn_id); + return mysql_affected_rows($this->conn_id); } // -------------------------------------------------------------------- @@ -361,7 +362,7 @@ class CI_DB_mysql_driver extends CI_DB { */ public function insert_id() { - return @mysql_insert_id($this->conn_id); + return mysql_insert_id($this->conn_id); } // -------------------------------------------------------------------- @@ -484,6 +485,8 @@ class CI_DB_mysql_driver extends CI_DB { */ protected function _close() { + // Error suppression to avoid annoying E_WARNINGs in cases + // where the connection has already been closed for some reason. @mysql_close($this->conn_id); } diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php index c232b5c90..68860e60c 100644 --- a/system/database/drivers/mysql/mysql_result.php +++ b/system/database/drivers/mysql/mysql_result.php @@ -50,7 +50,7 @@ class CI_DB_mysql_result extends CI_DB_result { // Required, due to mysql_data_seek() causing nightmares // with empty result sets - $this->num_rows = @mysql_num_rows($this->result_id); + $this->num_rows = mysql_num_rows($this->result_id); } // -------------------------------------------------------------------- @@ -74,7 +74,7 @@ class CI_DB_mysql_result extends CI_DB_result { */ public function num_fields() { - return @mysql_num_fields($this->result_id); + return mysql_num_fields($this->result_id); } // -------------------------------------------------------------------- @@ -153,7 +153,7 @@ class CI_DB_mysql_result extends CI_DB_result { public function data_seek($n = 0) { return $this->num_rows - ? @mysql_data_seek($this->result_id, $n) + ? mysql_data_seek($this->result_id, $n) : FALSE; } diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 316f17a5d..f34c0d117 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -261,7 +261,7 @@ class CI_DB_oci8_driver extends CI_DB { $this->stmt_id = FALSE; $this->_set_stmt_id($sql); oci_set_prefetch($this->stmt_id, 1000); - return @oci_execute($this->stmt_id, $this->commit_mode); + return oci_execute($this->stmt_id, $this->commit_mode); } // -------------------------------------------------------------------- @@ -451,7 +451,7 @@ class CI_DB_oci8_driver extends CI_DB { */ public function affected_rows() { - return @oci_num_rows($this->stmt_id); + return oci_num_rows($this->stmt_id); } // -------------------------------------------------------------------- @@ -697,7 +697,7 @@ class CI_DB_oci8_driver extends CI_DB { */ protected function _close() { - @oci_close($this->conn_id); + oci_close($this->conn_id); } } diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 177646273..50612ca67 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -94,7 +94,7 @@ class CI_DB_oci8_result extends CI_DB_result { */ public function num_fields() { - $count = @oci_num_fields($this->stmt_id); + $count = oci_num_fields($this->stmt_id); // if we used a limit we subtract it return ($this->limit_used) ? $count - 1 : $count; @@ -183,7 +183,7 @@ class CI_DB_oci8_result extends CI_DB_result { protected function _fetch_assoc() { $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id; - return @oci_fetch_assoc($id); + return oci_fetch_assoc($id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 14c85c8e2..06c24d66f 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -124,7 +124,7 @@ class CI_DB_odbc_driver extends CI_DB { */ protected function _execute($sql) { - return @odbc_exec($this->conn_id, $sql); + return odbc_exec($this->conn_id, $sql); } // -------------------------------------------------------------------- @@ -213,7 +213,7 @@ class CI_DB_odbc_driver extends CI_DB { */ public function affected_rows() { - return @odbc_num_rows($this->result_id); + return odbc_num_rows($this->result_id); } // -------------------------------------------------------------------- @@ -357,7 +357,7 @@ class CI_DB_odbc_driver extends CI_DB { */ protected function _close() { - @odbc_close($this->conn_id); + odbc_close($this->conn_id); } } diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index 5b2df3943..3a101cd7e 100644 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -49,7 +49,7 @@ class CI_DB_odbc_result extends CI_DB_result { { return $this->num_rows; } - elseif (($this->num_rows = @odbc_num_rows($this->result_id)) !== -1) + elseif (($this->num_rows = odbc_num_rows($this->result_id)) !== -1) { return $this->num_rows; } @@ -76,7 +76,7 @@ class CI_DB_odbc_result extends CI_DB_result { */ public function num_fields() { - return @odbc_num_fields($this->result_id); + return odbc_num_fields($this->result_id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index 904bdd5b3..1b8fbc9d4 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.php @@ -91,6 +91,8 @@ class CI_DB_pdo_result extends CI_DB_result { $field_names = array(); for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) { + // Might trigger an E_WARNING due to not all subdrivers + // supporting getColumnMeta() $field_names[$i] = @$this->result_id->getColumnMeta(); $field_names[$i] = $field_names[$i]['name']; } diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 6a2209755..c380a7c49 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -233,7 +233,7 @@ class CI_DB_postgre_driver extends CI_DB { */ protected function _execute($sql) { - return @pg_query($this->conn_id, $sql); + return pg_query($this->conn_id, $sql); } // -------------------------------------------------------------------- @@ -257,7 +257,7 @@ class CI_DB_postgre_driver extends CI_DB { // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE); - return (bool) @pg_query($this->conn_id, 'BEGIN'); + return (bool) pg_query($this->conn_id, 'BEGIN'); } // -------------------------------------------------------------------- @@ -275,7 +275,7 @@ class CI_DB_postgre_driver extends CI_DB { return TRUE; } - return (bool) @pg_query($this->conn_id, 'COMMIT'); + return (bool) pg_query($this->conn_id, 'COMMIT'); } // -------------------------------------------------------------------- @@ -293,7 +293,7 @@ class CI_DB_postgre_driver extends CI_DB { return TRUE; } - return (bool) @pg_query($this->conn_id, 'ROLLBACK'); + return (bool) pg_query($this->conn_id, 'ROLLBACK'); } // -------------------------------------------------------------------- @@ -355,7 +355,7 @@ class CI_DB_postgre_driver extends CI_DB { */ public function affected_rows() { - return @pg_affected_rows($this->result_id); + return pg_affected_rows($this->result_id); } // -------------------------------------------------------------------- @@ -632,7 +632,7 @@ class CI_DB_postgre_driver extends CI_DB { */ protected function _close() { - @pg_close($this->conn_id); + pg_close($this->conn_id); } } diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php index ec484e940..ab04af12c 100644 --- a/system/database/drivers/postgre/postgre_result.php +++ b/system/database/drivers/postgre/postgre_result.php @@ -47,7 +47,7 @@ class CI_DB_postgre_result extends CI_DB_result { { return is_int($this->num_rows) ? $this->num_rows - : $this->num_rows = @pg_num_rows($this->result_id); + : $this->num_rows = pg_num_rows($this->result_id); } // -------------------------------------------------------------------- @@ -59,7 +59,7 @@ class CI_DB_postgre_result extends CI_DB_result { */ public function num_fields() { - return @pg_num_fields($this->result_id); + return pg_num_fields($this->result_id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index dd9e1e849..a5dd6e036 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -102,8 +102,8 @@ class CI_DB_sqlite_driver extends CI_DB { protected function _execute($sql) { return $this->is_write_type($sql) - ? @sqlite_exec($this->conn_id, $sql) - : @sqlite_query($this->conn_id, $sql); + ? sqlite_exec($this->conn_id, $sql) + : sqlite_query($this->conn_id, $sql); } // -------------------------------------------------------------------- @@ -203,7 +203,7 @@ class CI_DB_sqlite_driver extends CI_DB { */ public function insert_id() { - return @sqlite_last_insert_rowid($this->conn_id); + return sqlite_last_insert_rowid($this->conn_id); } // -------------------------------------------------------------------- @@ -345,7 +345,7 @@ class CI_DB_sqlite_driver extends CI_DB { */ protected function _close() { - @sqlite_close($this->conn_id); + sqlite_close($this->conn_id); } } diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 58f2e3420..ec983d5b4 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -556,7 +556,7 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ protected function _close() { - @sqlsrv_close($this->conn_id); + sqlsrv_close($this->conn_id); } } |