CI_DB_result::unbuffered_row PHP Method

unbuffered_row() public method

Returns an unbuffered row and move pointer to next row
public unbuffered_row ( string $type = 'object' ) : mixed
$type string 'array', 'object' or a custom class name
return mixed
    public function unbuffered_row($type = 'object')
    {
        if ($type === 'array') {
            return $this->_fetch_assoc();
        } elseif ($type === 'object') {
            return $this->_fetch_object();
        }
        return $this->_fetch_object($type);
    }

Usage Example

Example #1
0
 /**
  * Generate XML data from a query result object
  *
  * @param	object	$query	Query result object
  * @param	array	$params	Any preferences
  * @return	string
  */
 public function xml_from_result(CI_DB_result $query, $params = array())
 {
     // Set our default values
     foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val) {
         if (!isset($params[$key])) {
             $params[$key] = $val;
         }
     }
     // Create variables for convenience
     extract($params);
     // Load the xml helper
     get_instance()->load->helper('xml');
     // Generate the result
     $xml = '<' . $root . '>' . $newline;
     while ($row = $query->unbuffered_row()) {
         $xml .= $tab . '<' . $element . '>' . $newline;
         foreach ($row as $key => $val) {
             $xml .= $tab . $tab . '<' . $key . '>' . xml_convert($val) . '</' . $key . '>' . $newline;
         }
         $xml .= $tab . '</' . $element . '>' . $newline;
     }
     return $xml . '</' . $root . '>' . $newline;
 }