当前位置: 首页>>代码示例>>PHP>>正文


PHP mysqli_stmt::free_result方法代码示例

本文整理汇总了PHP中mysqli_stmt::free_result方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_stmt::free_result方法的具体用法?PHP mysqli_stmt::free_result怎么用?PHP mysqli_stmt::free_result使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysqli_stmt的用法示例。


在下文中一共展示了mysqli_stmt::free_result方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fetchOldSchool

 /**
  * Fetch for non-mysqlnd environments
  *
  * @todo review support for custom classes
  * @todo review pros/cons of using store_result()
  * @todo fix statements using AS
  *
  * @param $int_fetch_mode
  * @return array|null|object|\stdClass
  */
 private function fetchOldSchool($int_fetch_mode)
 {
     $this->obj_stmt->store_result();
     $obj_meta = $this->obj_stmt->result_metadata();
     $arr_fields = $obj_meta->fetch_fields();
     $obj_result = NULL !== $this->str_result_class ? new $this->str_result_class() : new \stdClass();
     $arr_bind_fields = array();
     foreach ($arr_fields as $obj_field) {
         $arr_bind_fields[] =& $obj_result->{$obj_field->name};
     }
     call_user_func_array(array($this->obj_stmt, 'bind_result'), $arr_bind_fields);
     if (DB::FETCH_MODE_ONE === $int_fetch_mode) {
         if ($this->obj_stmt->fetch()) {
             $mix_data = $obj_result;
         } else {
             $mix_data = NULL;
         }
     } else {
         $mix_data = array();
         while ($this->obj_stmt->fetch()) {
             // Manual clone method - nasty, but required because of all the binding references
             // to avoid each row being === the last row in the result set
             $obj_row = NULL !== $this->str_result_class ? new $this->str_result_class() : new \stdClass();
             foreach ($arr_fields as $obj_field) {
                 $obj_row->{$obj_field->name} = $obj_result->{$obj_field->name};
             }
             $mix_data[] = $obj_row;
         }
     }
     $this->obj_stmt->free_result();
     return $mix_data;
 }
开发者ID:p13eater,项目名称:php-dbal,代码行数:42,代码来源:Statement.php

示例2: flush

 /**
  * Free memory associated with the resultset
  *
  * @return void
  */
 public function flush()
 {
     if ($this->result instanceof mysqli_stmt) {
         $this->result->free_result();
     }
     $this->result = null;
     $this->col_info = null;
     // Sanity check before using the handle
     if (empty($this->dbh) || !$this->dbh instanceof mysqli) {
         return;
     }
     // Clear out any results from a multi-query
     while (mysqli_more_results($this->dbh)) {
         mysqli_next_result($this->dbh);
     }
 }
开发者ID:mpeshev,项目名称:wp-db-driver,代码行数:21,代码来源:mysqli.php

示例3: fetchResource

 /**
  * @param \mysqli_stmt $resource
  * @param string       $column
  *
  * @return mixed[]
  */
 protected function fetchResource($resource, $column)
 {
     $result = [];
     $metadata = $resource->result_metadata();
     $fields = $metadata->fetch_fields();
     if (count($fields) == 0) {
         return [];
     }
     $variables = [];
     $data = [];
     foreach ($fields as $field) {
         $variables[] =& $data[$field->name];
     }
     $resource->bind_result(...$variables);
     while ($resource->fetch()) {
         $clone = [];
         foreach ($data as $key => $value) {
             $clone[$key] = $value;
         }
         $result[] = $clone;
     }
     $resource->free_result();
     $this->fixTypes($result, $fields, $column);
     return $result;
 }
开发者ID:binsoul,项目名称:db-platform-mysql,代码行数:31,代码来源:StatementResult.php

示例4: closeCursor

 /**
  * Closes the cursor, allowing the statement to be executed again.
  *
  * @return bool
  */
 public function closeCursor()
 {
     if ($stmt = $this->_stmt) {
         $this->_stmt->free_result();
         return $this->_stmt->reset();
     }
     return false;
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:13,代码来源:Mysqli.php

示例5: closeCursor

 /**
  * Closes the cursor, allowing the statement to be executed again.
  *
  * @return bool
  */
 public function closeCursor()
 {
     if ($stmt = $this->_stmt) {
         $mysqli = $this->_adapter->getConnection();
         while ($mysqli->next_result()) {
         }
         $this->_stmt->free_result();
         return $this->_stmt->reset();
     }
     return false;
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:16,代码来源:Mysqli.php

示例6: executeAndFetch

 function executeAndFetch($className = self::DEFAULT_CLASS_NAME, $type = self::RESULT_OBJECT, array $iteratorMap = null)
 {
     try {
         $this->execute();
     } catch (\Exception $ex) {
         throw $ex;
     }
     switch ($type) {
         case self::RESULT_OBJECT:
             $objectBuilder = $className != self::DEFAULT_CLASS_NAME ? new ObjectBuilderUtil($className) : null;
             return $this->fetchObject($className, $objectBuilder, $iteratorMap);
         case self::RESULT_ARRAY:
             return $this->fetchArray($iteratorMap);
         default:
             throw new \InvalidArgumentException('Invalid Return Type');
     }
     $this->stmt->free_result();
     if (!$this->reusable) {
         $this->stmt->close();
         unset($this->stmt);
     } else {
         $this->stmt->reset();
     }
 }
开发者ID:laiello,项目名称:perminator,代码行数:24,代码来源:MysqliPrepareStmt.php

示例7: _dynamicBindResults

 /**
  * This helper method takes care of prepared statements' "bind_result method
  * , when the number of variables to pass is unknown.
  *
  * @param mysqli_stmt $stmt Equal to the prepared statement object.
  *
  * @return array The results of the SQL fetch.
  */
 protected function _dynamicBindResults(mysqli_stmt $stmt)
 {
     $parameters = array();
     $results = array();
     // See http://php.net/manual/en/mysqli-result.fetch-fields.php
     $mysqlLongType = 252;
     $shouldStoreResult = false;
     $meta = $stmt->result_metadata();
     // if $meta is false yet sqlstate is true, there's no sql error but the query is
     // most likely an update/insert/delete which doesn't produce any results
     if (!$meta && $stmt->sqlstate) {
         return array();
     }
     $row = array();
     while ($field = $meta->fetch_field()) {
         if ($field->type == $mysqlLongType) {
             $shouldStoreResult = true;
         }
         if ($this->_nestJoin && $field->table != $this->_tableName) {
             $field->table = substr($field->table, strlen(self::$prefix));
             $row[$field->table][$field->name] = null;
             $parameters[] =& $row[$field->table][$field->name];
         } else {
             $row[$field->name] = null;
             $parameters[] =& $row[$field->name];
         }
     }
     // avoid out of memory bug in php 5.2 and 5.3. Mysqli allocates lot of memory for long*
     // and blob* types. So to avoid out of memory issues store_result is used
     // https://github.com/joshcam/PHP-MySQLi-Database-Class/pull/119
     if ($shouldStoreResult) {
         $stmt->store_result();
     }
     call_user_func_array(array($stmt, 'bind_result'), $parameters);
     $this->totalCount = 0;
     $this->count = 0;
     while ($stmt->fetch()) {
         if ($this->returnType == 'Object') {
             $x = new stdClass();
             foreach ($row as $key => $val) {
                 if (is_array($val)) {
                     $x->{$key} = new stdClass();
                     foreach ($val as $k => $v) {
                         $x->{$key}->{$k} = $v;
                     }
                 } else {
                     $x->{$key} = $val;
                 }
             }
         } else {
             $x = array();
             foreach ($row as $key => $val) {
                 $x[$key] = $val;
             }
         }
         $this->count++;
         array_push($results, $x);
     }
     if ($shouldStoreResult) {
         $stmt->free_result();
     }
     $stmt->close();
     // stored procedures sometimes can return more then 1 resultset
     if ($this->mysqli()->more_results()) {
         $this->mysqli()->next_result();
     }
     if (in_array('SQL_CALC_FOUND_ROWS', $this->_queryOptions)) {
         $stmt = $this->mysqli()->query('SELECT FOUND_ROWS()');
         $totalCount = $stmt->fetch_row();
         $this->totalCount = $totalCount[0];
     }
     if ($this->returnType == 'Json') {
         return json_encode($results);
     }
     return $results;
 }
开发者ID:abhijeetcpu,项目名称:PHP-MySQLi-Database-Class,代码行数:84,代码来源:MysqliDb.php

示例8: closeCursor

 /**
  * {@inheritdoc}
  */
 public function closeCursor()
 {
     $this->_stmt->free_result();
     return true;
 }
开发者ID:doctrine,项目名称:dbal,代码行数:8,代码来源:MysqliStatement.php

示例9: _dynamicBindResults

 private function _dynamicBindResults(mysqli_stmt $stmt)
 {
     $parameters = array();
     $results = array();
     $meta = $stmt->result_metadata();
     if (!$meta && $stmt->sqlstate) {
         return array();
     }
     $row = array();
     while ($field = $meta->fetch_field()) {
         $row[$field->name] = null;
         $parameters[] =& $row[$field->name];
     }
     $stmt->store_result();
     call_user_func_array(array($stmt, 'bind_result'), $parameters);
     $this->count = 0;
     while ($stmt->fetch()) {
         $result = array();
         foreach ($row as $key => $val) {
             $result[$key] = $val;
         }
         array_push($results, (object) $result);
         $this->count++;
     }
     $stmt->free_result();
     return $results;
 }
开发者ID:moimz,项目名称:MiniTalk.Client,代码行数:27,代码来源:mysql.class.php

示例10: fetchAll

 function fetchAll()
 {
     if (!$this->DB) {
         return;
     }
     $data = $this->Statement->result_metadata();
     $out = array();
     $fields = array();
     if (!$data) {
         return null;
     }
     $length = 0;
     while (null != ($field = mysqli_fetch_field($data))) {
         $fields[] =& $out[$field->name];
         $length += $field->length;
     }
     call_user_func_array(array($this->Statement, "bind_result"), $fields);
     $output = array();
     $count = 0;
     //FIXME: store_result is needed, but using it causes crash
     if ($length >= 1000000) {
         if (!$this->Statement->store_result()) {
             throw new \Exception("Store_Result error on MySQLi prepared statement : " . $this->Statement->get_warnings());
         }
     }
     while ($this->Statement->fetch()) {
         foreach ($out as $k => $v) {
             $output[$count][$k] = $v;
         }
         $count++;
     }
     $this->Statement->free_result();
     return $count == 0 ? null : $output;
 }
开发者ID:michalkoczwara,项目名称:WebGoatPHP,代码行数:34,代码来源:mysqli.php


注:本文中的mysqli_stmt::free_result方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。