CI_DB_result Class Reference

Inheritance diagram for CI_DB_result:

List of all members.


Public Member Functions

 result ($type= 'object')
 Query result.
 result_object ()
 Query result.
 result_array ()
 Query result.
 row ($n=0, $type= 'object')
 Query result.
 set_row ($key, $value=NULL)
 Assigns an item into a particular column slot.
 row_object ($n=0)
 Returns a single result row - object version.
 row_array ($n=0)
 Returns a single result row - array version.
 first_row ($type= 'object')
 Returns the "first" row.
 last_row ($type= 'object')
 Returns the "last" row.
 next_row ($type= 'object')
 Returns the "next" row.
 previous_row ($type= 'object')
 Returns the "previous" row.
 num_rows ()
 The following functions are normally overloaded by the identically named methods in the platform-specific driver -- except when query caching is used.
 num_fields ()
 list_fields ()
 field_data ()
 free_result ()
 _data_seek ()
 _fetch_assoc ()
 _fetch_object ()

Public Attributes

 $conn_id = NULL
 $result_id = NULL
 $result_array = array()
 $result_object = array()
 $current_row = 0
 $num_rows = 0
 $row_data = NULL

Detailed Description

Definition at line 29 of file DB_result.php.


Member Function Documentation

CI_DB_result::_data_seek (  ) 

Definition at line 334 of file DB_result.php.

Referenced by result_array(), and result_object().

00334 { return TRUE; }

Here is the caller graph for this function:

CI_DB_result::_fetch_assoc (  ) 

Reimplemented in CI_DB_mssql_result, CI_DB_mysql_result, CI_DB_mysqli_result, CI_DB_odbc_result, CI_DB_postgre_result, and CI_DB_sqlite_result.

Definition at line 335 of file DB_result.php.

Referenced by CI_DB_oci8_result::result_array(), and result_array().

00335 { return array(); }     

Here is the caller graph for this function:

CI_DB_result::_fetch_object (  ) 

Reimplemented in CI_DB_mssql_result, CI_DB_mysql_result, CI_DB_mysqli_result, CI_DB_oci8_result, CI_DB_odbc_result, CI_DB_postgre_result, and CI_DB_sqlite_result.

Definition at line 336 of file DB_result.php.

Referenced by result_object().

00336 { return array(); }

Here is the caller graph for this function:

CI_DB_result::field_data (  ) 

CI_DB_result::first_row ( type = 'object'  ) 

Returns the "first" row.

public

Returns:
object

Definition at line 239 of file DB_result.php.

References result().

00240         {
00241                 $result = $this->result($type);
00242 
00243                 if (count($result) == 0)
00244                 {
00245                         return $result;
00246                 }
00247                 return $result[0];
00248         }

Here is the call graph for this function:

CI_DB_result::free_result (  ) 

CI_DB_result::last_row ( type = 'object'  ) 

Returns the "last" row.

public

Returns:
object

Definition at line 258 of file DB_result.php.

References result().

00259         {
00260                 $result = $this->result($type);
00261 
00262                 if (count($result) == 0)
00263                 {
00264                         return $result;
00265                 }
00266                 return $result[count($result) -1];
00267         }       

Here is the call graph for this function:

CI_DB_result::list_fields (  ) 

CI_DB_result::next_row ( type = 'object'  ) 

Returns the "next" row.

public

Returns:
object

Definition at line 277 of file DB_result.php.

References result().

00278         {
00279                 $result = $this->result($type);
00280 
00281                 if (count($result) == 0)
00282                 {
00283                         return $result;
00284                 }
00285 
00286                 if (isset($result[$this->current_row + 1]))
00287                 {
00288                         ++$this->current_row;
00289                 }
00290                                 
00291                 return $result[$this->current_row];
00292         }

Here is the call graph for this function:

CI_DB_result::num_fields (  ) 

CI_DB_result::num_rows (  ) 

The following functions are normally overloaded by the identically named methods in the platform-specific driver -- except when query caching is used.

When caching is enabled we do not load the other driver. These functions are primarily here to prevent undefined function errors when a cached result object is in use. They are not otherwise fully operational due to the unavailability of the database resource IDs with cached results.

Reimplemented in CI_DB_mssql_result, CI_DB_mysql_result, CI_DB_mysqli_result, CI_DB_oci8_result, CI_DB_odbc_result, CI_DB_postgre_result, and CI_DB_sqlite_result.

Definition at line 329 of file DB_result.php.

Referenced by result_array(), and result_object().

00329 { return $this->num_rows; }

Here is the caller graph for this function:

CI_DB_result::previous_row ( type = 'object'  ) 

Returns the "previous" row.

public

Returns:
object

Definition at line 302 of file DB_result.php.

References result().

00303         {
00304                 $result = $this->result($type);
00305 
00306                 if (count($result) == 0)
00307                 {
00308                         return $result;
00309                 }
00310 
00311                 if (isset($result[$this->current_row - 1]))
00312                 {
00313                         --$this->current_row;
00314                 }
00315                 return $result[$this->current_row];
00316         }

Here is the call graph for this function:

CI_DB_result::result ( type = 'object'  ) 

Query result.

Acts as a wrapper function for the following functions.

public

Parameters:
string can be "object" or "array"
Returns:
mixed either a result object or array

Definition at line 47 of file DB_result.php.

References result_array(), and result_object().

Referenced by first_row(), last_row(), next_row(), and previous_row().

00048         {       
00049                 return ($type == 'object') ? $this->result_object() : $this->result_array();
00050         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_result::result_array (  ) 

Query result.

"array" version.

public

Returns:
array

Reimplemented in CI_DB_oci8_result.

Definition at line 92 of file DB_result.php.

References _data_seek(), _fetch_assoc(), and num_rows().

Referenced by result(), and row_array().

00093         {
00094                 if (count($this->result_array) > 0)
00095                 {
00096                         return $this->result_array;
00097                 }
00098 
00099                 // In the event that query caching is on the result_id variable 
00100                 // will return FALSE since there isn't a valid SQL resource so 
00101                 // we'll simply return an empty array.
00102                 if ($this->result_id === FALSE OR $this->num_rows() == 0)
00103                 {
00104                         return array();
00105                 }
00106 
00107                 $this->_data_seek(0);
00108                 while ($row = $this->_fetch_assoc())
00109                 {
00110                         $this->result_array[] = $row;
00111                 }
00112                 
00113                 return $this->result_array;
00114         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_result::result_object (  ) 

Query result.

"object" version.

public

Returns:
object

Definition at line 60 of file DB_result.php.

References _data_seek(), _fetch_object(), and num_rows().

Referenced by result(), and row_object().

00061         {
00062                 if (count($this->result_object) > 0)
00063                 {
00064                         return $this->result_object;
00065                 }
00066                 
00067                 // In the event that query caching is on the result_id variable 
00068                 // will return FALSE since there isn't a valid SQL resource so 
00069                 // we'll simply return an empty array.
00070                 if ($this->result_id === FALSE OR $this->num_rows() == 0)
00071                 {
00072                         return array();
00073                 }
00074 
00075                 $this->_data_seek(0);
00076                 while ($row = $this->_fetch_object())
00077                 {
00078                         $this->result_object[] = $row;
00079                 }
00080                 
00081                 return $this->result_object;
00082         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_result::row ( n = 0,
type = 'object' 
)

Query result.

Acts as a wrapper function for the following functions.

public

Parameters:
string 
string can be "object" or "array"
Returns:
mixed either a result object or array

Definition at line 126 of file DB_result.php.

References row_array(), and row_object().

00127         {
00128                 if ( ! is_numeric($n))
00129                 {
00130                         // We cache the row data for subsequent uses
00131                         if ( ! is_array($this->row_data))
00132                         {
00133                                 $this->row_data = $this->row_array(0);
00134                         }
00135                 
00136                         // array_key_exists() instead of isset() to allow for MySQL NULL values
00137                         if (array_key_exists($n, $this->row_data))
00138                         {
00139                                 return $this->row_data[$n];
00140                         }
00141                         // reset the $n variable if the result was not achieved                 
00142                         $n = 0;
00143                 }
00144                 
00145                 return ($type == 'object') ? $this->row_object($n) : $this->row_array($n);
00146         }

Here is the call graph for this function:

CI_DB_result::row_array ( n = 0  ) 

Returns a single result row - array version.

public

Returns:
array

Definition at line 213 of file DB_result.php.

References result_array().

Referenced by row(), and set_row().

00214         {
00215                 $result = $this->result_array();
00216 
00217                 if (count($result) == 0)
00218                 {
00219                         return $result;
00220                 }
00221                         
00222                 if ($n != $this->current_row AND isset($result[$n]))
00223                 {
00224                         $this->current_row = $n;
00225                 }
00226                 
00227                 return $result[$this->current_row];
00228         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_result::row_object ( n = 0  ) 

Returns a single result row - object version.

public

Returns:
object

Definition at line 188 of file DB_result.php.

References result_object().

Referenced by row().

00189         {
00190                 $result = $this->result_object();
00191                 
00192                 if (count($result) == 0)
00193                 {
00194                         return $result;
00195                 }
00196 
00197                 if ($n != $this->current_row AND isset($result[$n]))
00198                 {
00199                         $this->current_row = $n;
00200                 }
00201 
00202                 return $result[$this->current_row];
00203         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_result::set_row ( key,
value = NULL 
)

Assigns an item into a particular column slot.

public

Returns:
object

Definition at line 156 of file DB_result.php.

References row_array().

00157         {
00158                 // We cache the row data for subsequent uses
00159                 if ( ! is_array($this->row_data))
00160                 {
00161                         $this->row_data = $this->row_array(0);
00162                 }
00163         
00164                 if (is_array($key))
00165                 {
00166                         foreach ($key as $k => $v)
00167                         {
00168                                 $this->row_data[$k] = $v;
00169                         }
00170                         
00171                         return;
00172                 }
00173         
00174                 if ($key != '' AND ! is_null($value))
00175                 {
00176                         $this->row_data[$key] = $value;
00177                 }
00178         }

Here is the call graph for this function:


Member Data Documentation

CI_DB_result::$conn_id = NULL

Definition at line 31 of file DB_result.php.

CI_DB_result::$current_row = 0

Definition at line 35 of file DB_result.php.

CI_DB_result::$num_rows = 0

Definition at line 36 of file DB_result.php.

CI_DB_result::$result_array = array()

Definition at line 33 of file DB_result.php.

CI_DB_result::$result_id = NULL

Definition at line 32 of file DB_result.php.

CI_DB_result::$result_object = array()

Definition at line 34 of file DB_result.php.

CI_DB_result::$row_data = NULL

Definition at line 37 of file DB_result.php.


The documentation for this class was generated from the following file: