Permalink
Browse files

Add a base result class for native drivers

  • Loading branch information...
1 parent b5659f7 commit d842110bc4f4ae8f4644f573fc5945dc33e45817 @narfbg narfbg committed Jul 24, 2012
@@ -35,33 +35,7 @@
* @link http://codeigniter.com/user_guide/database/
* @since 2.1
*/
-class CI_DB_native_cubrid_result extends CI_DB_result {
-
- /**
- * Number of rows in the result set
- *
- * @return int
- */
- public function num_rows()
- {
- return is_int($this->num_rows)
- ? $this->num_rows
- : $this->num_rows = @cubrid_num_rows($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Number of fields in the result set
- *
- * @return int
- */
- public function num_fields()
- {
- return @cubrid_num_fields($this->result_id);
- }
-
- // --------------------------------------------------------------------
+class CI_DB_native_cubrid_result extends CI_DB_native_result {
/**
* Fetch Field Names
@@ -142,20 +116,6 @@ protected function _data_seek($n = 0)
// --------------------------------------------------------------------
/**
- * Result - associative array
- *
- * Returns the result set as an array
- *
- * @return array
- */
- protected function _fetch_assoc()
- {
- return cubrid_fetch_assoc($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Result - object
*
* Returns the result set as an object
@@ -35,19 +35,7 @@
* @link http://codeigniter.com/user_guide/database/
* @since 3.0
*/
-class CI_DB_native_ibase_result extends CI_DB_result {
-
- /**
- * Number of fields in the result set
- *
- * @return int
- */
- public function num_fields()
- {
- return @ibase_num_fields($this->result_id);
- }
-
- // --------------------------------------------------------------------
+class CI_DB_native_ibase_result extends CI_DB_native_result {
/**
* Fetch Field Names
@@ -98,18 +86,6 @@ public function field_data()
// --------------------------------------------------------------------
/**
- * Free the result
- *
- * @return void
- */
- public function free_result()
- {
- @ibase_free_result($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Result - associative array
*
* Returns the result set as an array
@@ -35,33 +35,7 @@
* @link http://codeigniter.com/user_guide/database/
* @since 1.3
*/
-class CI_DB_native_mssql_result extends CI_DB_result {
-
- /**
- * Number of rows in the result set
- *
- * @return int
- */
- public function num_rows()
- {
- return is_int($this->num_rows)
- ? $this->num_rows
- : $this->num_rows = @mssql_num_rows($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Number of fields in the result set
- *
- * @return int
- */
- public function num_fields()
- {
- return @mssql_num_fields($this->result_id);
- }
-
- // --------------------------------------------------------------------
+class CI_DB_native_mssql_result extends CI_DB_native_result {
/**
* Fetch Field Names
@@ -111,22 +85,6 @@ public function field_data()
// --------------------------------------------------------------------
/**
- * Free the result
- *
- * @return void
- */
- public function free_result()
- {
- if (is_resource($this->result_id))
- {
- mssql_free_result($this->result_id);
- $this->result_id = FALSE;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
@@ -143,20 +101,6 @@ protected function _data_seek($n = 0)
// --------------------------------------------------------------------
/**
- * Result - associative array
- *
- * Returns the result set as an array
- *
- * @return array
- */
- protected function _fetch_assoc()
- {
- return mssql_fetch_assoc($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Result - object
*
* Returns the result set as an object
@@ -35,33 +35,7 @@
* @link http://codeigniter.com/user_guide/database/
* @since 1.3
*/
-class CI_DB_native_mysqli_result extends CI_DB_result {
-
- /**
- * Number of rows in the result set
- *
- * @return int
- */
- public function num_rows()
- {
- return is_int($this->num_rows)
- ? $this->num_rows
- : $this->num_rows = $this->result_id->num_rows;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Number of fields in the result set
- *
- * @return int
- */
- public function num_fields()
- {
- return $this->result_id->field_count;
- }
-
- // --------------------------------------------------------------------
+class CI_DB_native_mysqli_result extends CI_DB_native_result {
/**
* Fetch Field Names
@@ -110,22 +84,6 @@ public function field_data()
// --------------------------------------------------------------------
/**
- * Free the result
- *
- * @return void
- */
- public function free_result()
- {
- if (is_object($this->result_id))
- {
- $this->result_id->free();
- $this->result_id = FALSE;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
@@ -142,20 +100,6 @@ protected function _data_seek($n = 0)
// --------------------------------------------------------------------
/**
- * Result - associative array
- *
- * Returns the result set as an array
- *
- * @return array
- */
- protected function _fetch_assoc()
- {
- return $this->result_id->fetch_assoc();
- }
-
- // --------------------------------------------------------------------
-
- /**
* Result - object
*
* Returns the result set as an object
@@ -35,7 +35,7 @@
* @link http://codeigniter.com/user_guide/database/
* @since 1.4.1
*/
-class CI_DB_native_oci8_result extends CI_DB_result {
+class CI_DB_native_oci8_result extends CI_DB_native_result {
public $stmt_id;
public $curs_id;
@@ -35,50 +35,7 @@
* @link http://codeigniter.com/user_guide/database/
* @since 1.3
*/
-class CI_DB_native_odbc_result extends CI_DB_result {
-
- /**
- * Number of rows in the result set
- *
- * @return int
- */
- public function num_rows()
- {
- if (is_int($this->num_rows))
- {
- return $this->num_rows;
- }
- elseif (($this->num_rows = @odbc_num_rows($this->result_id)) !== -1)
- {
- return $this->num_rows;
- }
-
- // Work-around for ODBC subdrivers that don't support num_rows()
- if (count($this->result_array) > 0)
- {
- return $this->num_rows = count($this->result_array);
- }
- elseif (count($this->result_object) > 0)
- {
- return $this->num_rows = count($this->result_object);
- }
-
- return $this->num_rows = count($this->result_array());
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Number of fields in the result set
- *
- * @return int
- */
- public function num_fields()
- {
- return @odbc_num_fields($this->result_id);
- }
-
- // --------------------------------------------------------------------
+class CI_DB_native_odbc_result extends CI_DB_native_result {
/**
* Fetch Field Names
@@ -131,22 +88,6 @@ public function field_data()
// --------------------------------------------------------------------
/**
- * Free the result
- *
- * @return void
- */
- public function free_result()
- {
- if (is_resource($this->result_id))
- {
- odbc_free_result($this->result_id);
- $this->result_id = FALSE;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
* Result - associative array
*
* Returns the result set as an array
Oops, something went wrong.

0 comments on commit d842110

Please sign in to comment.