/**
  * Returns the result of calling for query using the callback
  *
  * @return mixed the result of the callback function, or NULL
  */
 public function delegate_current(\MySQLi_Result $pointer)
 {
     $current = $pointer->fetch_object();
     if ($current === null) {
         return null;
     }
     // Prepare the arguments
     $args = array();
     foreach ($this->args as $arg) {
         $args[] = $arg->format($current);
     }
     return call_user_func_array($this->callback, $args);
 }
Example #2
0
 /**
  * Returns the object at the given pointer, possibly from DBI cache
  *
  */
 public function delegate_current(\MySQLi_Result $pointer)
 {
     $obj = $pointer->fetch_object($this->object_type);
     if ($obj === null) {
         return null;
     }
     if ($obj->db_get_cache()) {
         if (($cache = $this->dbi->getCached($obj, $obj->id)) !== null) {
             return $cache;
         }
         $this->dbi->setCached($obj);
     }
     $obj->db_set_dbi($this->dbi);
     return $obj;
 }
Example #3
0
 /**
  * Frees memory associated with the result.
  */
 public function free()
 {
     if ($this->_open === true) {
         $this->_result->free();
         $this->_open = false;
     }
 }
Example #4
0
 /**
  * Get the name of the fields in an array
  * 
  * @access public
  * @since 2.3
  * @return array 
  */
 function listFields()
 {
     $fieldNames = array();
     while ($field = $this->resultId->fetch_field()) {
         $fieldNames[] = $field->name;
     }
     return $fieldNames;
 }
Example #5
0
 /**
  * Seek the resultset to a certain index.
  *
  * @param integer $offset Offset to seek to.
  */
 protected function jumpTo($offset)
 {
     if ($offset != $this->row_pointer) {
         if ($this->offsetExists($offset)) {
             $this->result->data_seek($offset);
         }
         $this->row_pointer = $offset;
     }
 }
Example #6
0
 /**
  * Fetch rows of query result as associative array
  *
  * @param string $query
  * @param string $valueAsArrayIndex If not null you need to define a field name of the table
  *  e.g. your table has {id, name, email} fields, if you set it to 'name' the key of resulting
  *  array is the value of the field 'name'
  * @return array[]
  */
 public function fetchAsAssoc($query, $valueAsArrayIndex = null)
 {
     $fetch = array();
     $this->query($query);
     while ($row = $this->lastResult->fetch_assoc()) {
         if ($valueAsArrayIndex) {
             if (!isset($row[$valueAsArrayIndex])) {
                 error("Field '{$valueAsArrayIndex}' does not exist in SQL Result");
             }
             $fetch[$row[$valueAsArrayIndex]] = $row;
         } else {
             $fetch[] = $row;
         }
     }
     return $fetch;
 }
Example #7
0
 /**
  * Returns the formatted object at the given pointer
  *
  */
 public function delegate_current(\MySQLi_Result $pointer)
 {
     return $pointer->fetch_object($this->object_type, $this->object_args);
 }
 /**
  * Return the next row of results from the last query.
  *
  * @return array
  */
 function getRow()
 {
     return $this->resid ? $this->resid->fetch_assoc() : false;
 }
Example #9
0
 public function __construct($result, $class = null)
 {
     parent::__construct($result);
     $this->class = $class;
 }
Example #10
0
 /**
  * Internal method to free the result resource
  *
  * @return null
  */
 public function free()
 {
     $this->result->free();
 }
Example #11
0
 public function fetch_row($type_cast = false)
 {
     return $type_cast ? $this->type_cast(parent::fetch_row()) : parent::fetch_row();
 }