summaryrefslogtreecommitdiffstats
path: root/system/database/drivers
diff options
context:
space:
mode:
authorTimothy Warren <tim@timshomepage.net>2012-03-01 15:40:37 +0100
committerTimothy Warren <tim@timshomepage.net>2012-03-01 15:40:37 +0100
commita0da0b28bdb0ff73d5c0d9f8780ab0f6d74f39e3 (patch)
tree67b3789312fb4056352d83432c60644648c9feac /system/database/drivers
parent7842b1bc8cc007521dcc55de613d6e3224cfe2c1 (diff)
parented7408282e9fded97ade222f98b43623a0f17d22 (diff)
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into firebird
Diffstat (limited to 'system/database/drivers')
-rw-r--r--system/database/drivers/oci8/oci8_driver.php14
-rw-r--r--system/database/drivers/odbc/odbc_result.php58
-rw-r--r--system/database/drivers/pdo/pdo_driver.php7
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php35
4 files changed, 70 insertions, 44 deletions
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index c6621901b..057095c23 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -398,10 +398,9 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Escape String
*
- * @access public
- * @param string
+ * @param string
* @param bool whether or not the string will be used in a LIKE condition
- * @return string
+ * @return string
*/
public function escape_str($str, $like = FALSE)
{
@@ -415,15 +414,14 @@ class CI_DB_oci8_driver extends CI_DB {
return $str;
}
- $str = remove_invisible_characters($str);
- $str = str_replace("'", "''", $str);
+ $str = str_replace("'", "''", remove_invisible_characters($str));
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = str_replace( array('%', '_', $this->_like_escape_chr),
- array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
- $str);
+ return str_replace(array($this->_like_escape_chr, '%', '_'),
+ array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
+ $str);
}
return $str;
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index ba660856e..572e110ca 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -38,15 +38,27 @@
*/
class CI_DB_odbc_result extends CI_DB_result {
+ public $num_rows;
+
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
- return @odbc_num_rows($this->result_id);
+ if (is_int($this->num_rows))
+ {
+ return $this->num_rows;
+ }
+
+ // Work-around for ODBC subdrivers that don't support num_rows()
+ if (($this->num_rows = @odbc_num_rows($this->result_id)) === -1)
+ {
+ $this->num_rows = count($this->result_array());
+ }
+
+ return $this->num_rows;
}
// --------------------------------------------------------------------
@@ -54,10 +66,9 @@ class CI_DB_odbc_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @odbc_num_fields($this->result_id);
}
@@ -69,15 +80,19 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
+ $num_fields = $this->num_fields();
+
+ if ($num_fields > 0)
{
- $field_names[] = odbc_field_name($this->result_id, $i);
+ for ($i = 1; $i <= $num_fields; $i++)
+ {
+ $field_names[] = odbc_field_name($this->result_id, $i);
+ }
}
return $field_names;
@@ -90,22 +105,19 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
+ for ($i = 0, $odbc_index = 1, $c = $this->num_fields(); $i < $c; $i++, $odbc_index++)
{
- $F = new stdClass();
- $F->name = odbc_field_name($this->result_id, $i);
- $F->type = odbc_field_type($this->result_id, $i);
- $F->max_length = odbc_field_len($this->result_id, $i);
- $F->primary_key = 0;
- $F->default = '';
-
- $retval[] = $F;
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = odbc_field_name($this->result_id, $odbc_index);
+ $retval[$i]->type = odbc_field_type($this->result_id, $odbc_index);
+ $retval[$i]->max_length = odbc_field_len($this->result_id, $odbc_index);
+ $retval[$i]->primary_key = 0;
+ $retval[$i]->default = '';
}
return $retval;
@@ -237,4 +249,4 @@ class CI_DB_odbc_result extends CI_DB_result {
/* End of file odbc_result.php */
-/* Location: ./system/database/drivers/odbc/odbc_result.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/odbc/odbc_result.php */
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index de2b0abeb..44e93a042 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -306,12 +306,11 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* 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);
}
// --------------------------------------------------------------------
@@ -950,4 +949,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/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 9c50209ec..e4fd90240 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -424,13 +424,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 +443,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 '';
}
// --------------------------------------------------------------------