public function __destruct()
 {
     if (is_object($this->handle)) {
         $this->handle->free();
     }
     // Don't close statement as these may be re-used across the life of this request
     // if (is_object($this->statement)) $this->statement->close();
 }
 public function &free()
 {
     if ($this->m_error instanceof ZDatabaseQueryError) {
         unset($this->m_error);
     }
     $this->m_error = null;
     if ($this->m_result instanceof mysqli_result) {
         $this->m_result->free();
     }
     return $this;
 }
Пример #3
0
 /**
  * @param mysqli_result $mysqli_result
  * @param bool $single
  * @return array|bool|null
  */
 public function fetch($mysqli_result, $single)
 {
     $this->_('fields', array());
     foreach ($mysqli_result->fetch_fields() as $field) {
         $this->_('fields')[$field->name] = $this->rules[$this->types[$field->type]];
     }
     switch (true) {
         case !$mysqli_result:
             return null;
         case $single && $mysqli_result->num_rows == 0:
             $result = false;
             break;
         case $single:
             $result = $this->cast($mysqli_result->fetch_assoc());
             break;
         case $mysqli_result->num_rows == 0:
             $result = array();
             break;
         default:
             $result = array();
             while ($row = $mysqli_result->fetch_assoc()) {
                 $result[] = $this->cast($row);
             }
     }
     $mysqli_result->free();
     return $result;
 }
 /**
  * Binds this statement to the variables
  */
 protected function bind()
 {
     $variables = array();
     // Bind each field
     while ($field = $this->metadata->fetch_field()) {
         $this->columns[] = $field->name;
         // Note that while boundValues isn't initialised at this point,
         // later calls to $this->statement->fetch() Will populate
         // $this->boundValues later with the next result.
         $variables[] =& $this->boundValues[$field->name];
     }
     call_user_func_array(array($this->statement, 'bind_result'), $variables);
     $this->bound = true;
     $this->metadata->free();
     // Buffer all results
     $this->statement->store_result();
 }
Пример #5
0
 /**
  * @see \Iterator::current()
  *
  * @return mixed
  * @throws \OutOfRangeException
  */
 public function current()
 {
     // Seems overkill to define our own OutOfRangeException. Use default in this case
     if ($this->_pointer > $this->_numberOfRows - 1) {
         throw new \OutOfRangeException('Attempting to access a row that is outside of the number of rows in this result.');
     }
     $pointer = $this->_pointer;
     if (!array_key_exists($this->_pointer, $this->_mysqlResult)) {
         $this->_mysqlResult[$this->_pointer] = $this->_result->fetch_array(\MYSQLI_ASSOC);
         $this->_pointer++;
         $this->_moveToNextRow = true;
         $this->_processedRows++;
         // Free up results when there is no more row to process
         if ($this->_processedRows === $this->_numberOfRows) {
             $this->_result->free();
         }
     }
     return $this->_mysqlResult[$pointer];
 }
Пример #6
0
 /**
  * 
  * 关闭 stmt result mysqli的函数,传入这三个东西就行
  * @param mysqli,stmt,result
  */
 static function close(mysqli $mysqli = null, mysqli_stmt $stmt = null, mysqli_result $result = null)
 {
     if ($result != null) {
         $result->free();
     }
     if ($stmt != null) {
         $stmt->close();
     }
     if ($mysqli != null) {
         $mysqli->close();
     }
 }
Пример #7
0
 /**
  * 释放资源
  */
 public function free()
 {
     if ($this->result) {
         $this->result->free();
         $mysql = $this->mysql->connect();
         while ($mysql->more_results() && $mysql->next_result()) {
             $result = $mysql->store_result();
             if ($result) {
                 $result->free();
             }
         }
     }
 }
Пример #8
0
 /**
  * @param \mysqli_result $resource
  * @param string         $column
  *
  * @return mixed[]
  */
 protected function fetchResource($resource, $column)
 {
     $fields = $resource->fetch_fields();
     if (count($fields) == 0) {
         return [];
     }
     $result = $resource->fetch_all(MYSQLI_ASSOC);
     if (!is_array($result)) {
         return [];
     }
     $resource->free();
     $this->fixTypes($result, $fields, $column);
     return $result;
 }
Пример #9
0
 /**
  * free mysql resource
  *
  * @param \mysqli_result $res
  *
  * @throws DatabaseException|\Exception
  * @return bool
  */
 public function free($res)
 {
     $res->free();
     return true;
 }
Пример #10
0
 public function __destruct()
 {
     $this->result->free();
 }
Пример #11
0
 /**
  * 释放所有与上次查询结果所关联的内存
  * @return bool
  */
 public function free()
 {
     return $this->result->free();
 }
Пример #12
0
 /**
  * @inheritdoc
  */
 public function __destruct()
 {
     if (is_object($this->result)) {
         $this->result->free();
     }
 }
Пример #13
0
 /**
  * 释放sql查询结果
  *
  * @param \mysqli_result $res 要释放的结果
  * @return bool 成功返回true,失败返回false
  */
 protected function _free($res)
 {
     return $res->free();
 }
Пример #14
0
 /**
  * Get all rows from the DB result.
  *
  * @param \mysqli_result|bool $result The return of query method.
  *
  * @return array The array of SQL rows
  */
 public function getRowsArray($result)
 {
     $rows = [];
     if (!$result) {
         return $rows;
     }
     while ($row = $result->fetch_assoc()) {
         $rows[] = $row;
     }
     $result->free();
     return $rows;
 }
 public function __destruct()
 {
     if (is_object($this->handle)) {
         $this->handle->free();
     }
 }
Пример #16
0
 /**
  * Free the result
  */
 public function free()
 {
     if (is_object($this->resResult)) {
         $this->resResult->free();
     }
 }
Пример #17
0
 /**
  * Result destruction cleans up all open result sets
  */
 public function __destruct()
 {
     if (is_resource($this->_result)) {
         $this->_result->free();
     }
 }
Пример #18
0
 /**
  * Uvolnit vysledek dotazu
  * @param  mysqli_result $result
  * @return bool
  */
 public static function free(mysqli_result $result)
 {
     return $result->free();
 }
Пример #19
0
 /**
  * Free ResultSet memory
  *
  * @param mysqli_result $query
  *   The result resource that is being evaluated. This result comes from a call to mysql_query().
  * @return bool
  *   Returns true on success or false on failure.
  */
 function free_result($query)
 {
     if ($query instanceof mysqli_result) {
         return $query->free();
     }
     return FALSE;
 }
Пример #20
0
 /**
  * Fetch all rows of a result set as an array of objects
  *
  * If <var>key</var> is not empty then the returned array is indexed by the value of the database key.
  * Returns <var>null</var> if the query fails.
  *
  * @param   mysqli_result  $result The result object. A result set identifier returned by the select() function
  * @param   string         $key    The column name of the index to use
  * @return  array   If <var>key</var> is empty as sequential array of returned rows.
  */
 protected function _fetchObjectList($result, $key = '')
 {
     $array = array();
     while ($row = $result->fetch_object()) {
         if ($key) {
             $array[$row->{$key}] = $row;
         } else {
             $array[] = $row;
         }
     }
     $result->free();
     return $array;
 }