summaryrefslogtreecommitdiffstats
path: root/system/database/drivers
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-03-01 18:40:06 +0100
committerAndrey Andreev <narf@bofh.bg>2012-03-01 18:40:06 +0100
commitbb5dae46256cdcb0bcd204b6fa2fc628da6afb88 (patch)
tree058e70e73708290ea49d5ed5c6e8d58a166bb5d4 /system/database/drivers
parentca365356e49ee32a1f03aa2d58f452b2a494268c (diff)
parente3a68042c086acfc98ae273adbd8527af0c6ab8b (diff)
Merge upstream branch
Diffstat (limited to 'system/database/drivers')
-rw-r--r--system/database/drivers/cubrid/cubrid_driver.php27
-rw-r--r--system/database/drivers/mssql/mssql_driver.php16
-rw-r--r--system/database/drivers/oci8/oci8_driver.php16
-rw-r--r--system/database/drivers/odbc/odbc_driver.php15
-rw-r--r--system/database/drivers/pdo/pdo_driver.php54
-rw-r--r--system/database/drivers/postgre/postgre_driver.php18
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php18
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php51
8 files changed, 44 insertions, 171 deletions
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index cde719eae..42f08fbf6 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -156,24 +156,6 @@ class CI_DB_cubrid_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @access public
- * @param string
- * @param string
- * @return resource
- */
- function db_set_charset($charset, $collation)
- {
- // In CUBRID, there is no need to set charset or collation.
- // This is why returning true will allow the application continue
- // its normal process.
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Version number query string
*
* @access public
@@ -362,12 +344,11 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
- return @cubrid_affected_rows($this->conn_id);
+ return @cubrid_affected_rows();
}
// --------------------------------------------------------------------
@@ -801,4 +782,4 @@ class CI_DB_cubrid_driver extends CI_DB {
/* End of file cubrid_driver.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 25a32f364..2a4f2b575 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -138,22 +138,6 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @access public
- * @param string
- * @param string
- * @return resource
- */
- function db_set_charset($charset, $collation)
- {
- // @todo - add support if needed
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Execute the query
*
* @access private called by the base class
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 057095c23..d9acaaea6 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -139,22 +139,6 @@ class CI_DB_oci8_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @access public
- * @param string
- * @param string
- * @return resource
- */
- public function db_set_charset($charset, $collation)
- {
- // this is done upon connect
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Version number query string
*
* @access protected
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index c9aaa6e68..fc4d1d365 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -123,21 +123,6 @@ class CI_DB_odbc_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string
- * @param string
- * @return bool
- */
- public function db_set_charset($charset, $collation)
- {
- // @todo - add support if needed
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Version number query string
*
* @return string
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index de2b0abeb..90f0fd791 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -289,29 +289,13 @@ class CI_DB_pdo_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @access public
- * @param string
- * @param string
- * @return resource
- */
- function db_set_charset($charset, $collation)
- {
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Version number query string
*
- * @access public
* @return string
*/
- function _version()
+ protected function _version()
{
- return $this->conn_id->getAttribute(PDO::ATTR_CLIENT_VERSION);
+ return $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION);
}
// --------------------------------------------------------------------
@@ -510,33 +494,19 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Insert ID
- *
- * @access public
- * @return integer
+ *
+ * @return int
*/
- function insert_id($name=NULL)
+ public function insert_id($name = NULL)
{
- if ($this->pdodriver == 'pgsql')
- {
- //Convenience method for postgres insertid
- $v = $this->_version();
-
- $table = func_num_args() > 0 ? func_get_arg(0) : NULL;
-
- if ($table == NULL && $v >= '8.1')
- {
- $sql='SELECT LASTVAL() as ins_id';
- }
-
- $query = $this->query($sql);
- $row = $query->row();
-
- return $row->ins_id;
- }
- else
+ if ($this->pdodriver === 'pgsql' && $name === NULL && $this->_version() >= '8.1')
{
- return $this->conn_id->lastInsertId($name);
+ $query = $this->query('SELECT LASTVAL() AS ins_id');
+ $query = $query->row();
+ return $query->ins_id;
}
+
+ return $this->conn_id->lastInsertId($name);
}
// --------------------------------------------------------------------
@@ -950,4 +920,4 @@ class CI_DB_pdo_driver extends CI_DB {
}
/* End of file pdo_driver.php */
-/* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/pdo/pdo_driver.php */
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 42329bded..89541e5fa 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -147,22 +147,6 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @access public
- * @param string
- * @param string
- * @return resource
- */
- function db_set_charset($charset, $collation)
- {
- // @todo - add support if needed
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Version number query string
*
* @access public
@@ -712,4 +696,4 @@ class CI_DB_postgre_driver extends CI_DB {
/* End of file postgre_driver.php */
-/* Location: ./system/database/drivers/postgre/postgre_driver.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/postgre/postgre_driver.php */
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 28c3caecd..718501b20 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -141,22 +141,6 @@ class CI_DB_sqlite_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @access public
- * @param string
- * @param string
- * @return resource
- */
- function db_set_charset($charset, $collation)
- {
- // @todo - add support if needed
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Version number query string
*
* @access public
@@ -667,4 +651,4 @@ class CI_DB_sqlite_driver extends CI_DB {
/* End of file sqlite_driver.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 9c50209ec..9b9038189 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -144,22 +144,6 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @access public
- * @param string
- * @param string
- * @return resource
- */
- function db_set_charset($charset, $collation)
- {
- // @todo - add support if needed
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Execute the query
*
* @access private called by the base class
@@ -424,13 +408,18 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* The error message string
*
- * @access private
* @return string
*/
- function _error_message()
+ protected function _error_message()
{
- $error = array_shift(sqlsrv_errors());
- return !empty($error['message']) ? $error['message'] : null;
+ $error = sqlsrv_errors();
+ if ( ! is_array($error))
+ {
+ return '';
+ }
+
+ $error = array_shift($error);
+ return isset($error['message']) ? $error['message'] : '';
}
// --------------------------------------------------------------------
@@ -438,13 +427,25 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* The error message number
*
- * @access private
- * @return integer
+ * @return string
*/
- function _error_number()
+ protected function _error_number()
{
- $error = array_shift(sqlsrv_errors());
- return isset($error['SQLSTATE']) ? $error['SQLSTATE'] : null;
+ $error = sqlsrv_errors();
+ if ( ! is_array($error))
+ {
+ return '';
+ }
+ elseif (isset($error['SQLSTATE']))
+ {
+ return isset($error['code']) ? $error['SQLSTATE'].'/'.$error['code'] : $error['SQLSTATE'];
+ }
+ elseif (isset($error['code']))
+ {
+ return $error['code'];
+ }
+
+ return '';
}
// --------------------------------------------------------------------