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


PHP mysqli_stmt::store_result方法代码示例

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


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

示例1: storeResult

 /**
  * Transfers a result set from a prepared statement
  * @link http://www.php.net/manual/en/mysqli-stmt.store-result.php
  * @throws \mysqli_sql_exception
  * @return \classes\database\statement\MysqliPrepareStmt
  */
 public function storeResult()
 {
     if (!$this->stmt->store_result()) {
         throw new \mysqli_sql_exception('storeResult call fail');
     }
     return $this;
 }
开发者ID:laiello,项目名称:perminator,代码行数:13,代码来源:MysqliPrepareStmt.php

示例2: execute

 /**
  * Execute
  *
  * @param  ParameterContainer $parameters
  * @return mixed
  */
 public function execute($parameters = null)
 {
     if (!$this->isPrepared) {
         $this->prepare();
     }
     /** START Standard ParameterContainer Merging Block */
     if (!$this->parameterContainer instanceof ParameterContainer) {
         if ($parameters instanceof ParameterContainer) {
             $this->parameterContainer = $parameters;
             $parameters = null;
         } else {
             $this->parameterContainer = new ParameterContainer();
         }
     }
     if (is_array($parameters)) {
         $this->parameterContainer->setFromArray($parameters);
     }
     if ($this->parameterContainer->count() > 0) {
         $this->bindParametersFromContainer();
     }
     /** END Standard ParameterContainer Merging Block */
     if ($this->resource->execute() === false) {
         throw new Exception\RuntimeException($this->resource->error);
     }
     if ($this->bufferResults === true) {
         $this->resource->store_result();
         $this->isPrepared = false;
         $buffered = true;
     } else {
         $buffered = false;
     }
     $result = $this->driver->createResult($this->resource, $buffered);
     return $result;
 }
开发者ID:Rovak,项目名称:zf2,代码行数:40,代码来源:Statement.php

示例3: 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

示例4: bind

 /**
  * 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();
 }
开发者ID:nicocin,项目名称:silverstripe-framework,代码行数:20,代码来源:MySQLStatement.php

示例5: store_result

 public function store_result()
 {
     $retval = $this->statement->store_result();
     if (false === $retval) {
         throw new BeeHub_MySQL(self::mysqli()->error, self::mysqli()->errno);
     }
     return $retval;
 }
开发者ID:niekbosch,项目名称:BeeHub,代码行数:8,代码来源:BeeHub_DB.php

示例6: _execute

 /**
  * Executes a prepared statement.
  *
  * @param array $params OPTIONAL Values to bind to parameter placeholders.
  * @return bool
  * @throws Zend_Db_Statement_Mysqli_Exception
  */
 public function _execute(array $params = null)
 {
     if (!$this->_stmt) {
         return false;
     }
     // if no params were given as an argument to execute(),
     // then default to the _bindParam array
     if ($params === null) {
         $params = $this->_bindParam;
     }
     // send $params as input parameters to the statement
     if ($params) {
         array_unshift($params, str_repeat('s', count($params)));
         call_user_func_array(array($this->_stmt, 'bind_param'), $params);
     }
     // execute the statement
     $retval = $this->_stmt->execute();
     if ($retval === false) {
         /**
          * @see Zend_Db_Statement_Mysqli_Exception
          */
         require_once 'Zend/Db/Statement/Mysqli/Exception.php';
         throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement execute error : " . $this->_stmt->error);
     }
     // retain metadata
     if ($this->_meta === null) {
         $this->_meta = $this->_stmt->result_metadata();
         if ($this->_stmt->errno) {
             /**
              * @see Zend_Db_Statement_Mysqli_Exception
              */
             require_once 'Zend/Db/Statement/Mysqli/Exception.php';
             throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement metadata error: " . $this->_stmt->error);
         }
     }
     // statements that have no result set do not return metadata
     if ($this->_meta !== false) {
         // get the column names that will result
         $this->_keys = array();
         foreach ($this->_meta->fetch_fields() as $col) {
             $this->_keys[] = $this->_adapter->foldCase($col->name);
         }
         // set up a binding space for result variables
         $this->_values = array_fill(0, count($this->_keys), null);
         // set up references to the result binding space.
         // just passing $this->_values in the call_user_func_array()
         // below won't work, you need references.
         $refs = array();
         foreach ($this->_values as $i => &$f) {
             $refs[$i] =& $f;
         }
         $this->_stmt->store_result();
         // bind to the result variables
         call_user_func_array(array($this->_stmt, 'bind_result'), $this->_values);
     }
     return $retval;
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:64,代码来源:Mysqli.php

示例7: buffer

 /**
  * Force buffering
  *
  * @throws Exception\RuntimeException
  */
 public function buffer()
 {
     if ($this->resource instanceof \mysqli_stmt && $this->isBuffered !== true) {
         if ($this->position > 0) {
             throw new Exception\RuntimeException('Cannot buffer a result set that has started iteration.');
         }
         $this->resource->store_result();
         $this->isBuffered = true;
     }
 }
开发者ID:CHRISTOPHERVANDOMME,项目名称:zf2complet,代码行数:15,代码来源:Result.php

示例8: getFetchArrays

 /**
  * Get all array data
  *
  * @return array
  */
 public function getFetchArrays()
 {
     $data = array();
     if ($this->resource instanceof \mysqli_result) {
         $result = $this->resource;
     } else {
         if ($this->resource instanceof \mysqli_stmt) {
             $result = $this->resource->get_result();
         } else {
             if ($this->resource instanceof \mysqli) {
                 $result = $this->resource->store_result();
             }
         }
     }
     while ($row = $result->fetch_array(\MYSQLI_ASSOC)) {
         $data[] = $row;
     }
     return $data;
 }
开发者ID:musicsnap,项目名称:Yaf.Global.Library,代码行数:24,代码来源:Result.php

示例9: execute

 /**
  * {@inheritdoc}
  */
 public function execute($params = null)
 {
     if (null !== $this->_bindedValues) {
         if (null !== $params) {
             if (!$this->_bindValues($params)) {
                 throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
             }
         } else {
             if (!call_user_func_array(array($this->_stmt, 'bind_param'), $this->_bindedValues)) {
                 throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
             }
         }
     }
     if (!$this->_stmt->execute()) {
         throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
     }
     if (null === $this->_columnNames) {
         $meta = $this->_stmt->result_metadata();
         if (false !== $meta) {
             $columnNames = array();
             foreach ($meta->fetch_fields() as $col) {
                 $columnNames[] = $col->name;
             }
             $meta->free();
             $this->_columnNames = $columnNames;
             $this->_rowBindedValues = array_fill(0, count($columnNames), NULL);
             $refs = array();
             foreach ($this->_rowBindedValues as $key => &$value) {
                 $refs[$key] =& $value;
             }
             if (!call_user_func_array(array($this->_stmt, 'bind_result'), $refs)) {
                 throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
             }
         } else {
             $this->_columnNames = false;
         }
     }
     // We have a result.
     if (false !== $this->_columnNames) {
         $this->_stmt->store_result();
     }
     return true;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:46,代码来源:MysqliStatement.php

示例10: _getResults

 /**
  * Gets the results of the query
  */
 private function _getResults()
 {
     $meta = $this->_query->result_metadata();
     $parameters = array();
     $results = array();
     $row = array();
     while ($field = $meta->fetch_field()) {
         $row[$field->name] = null;
         $parameters[] =& $row[$field->name];
     }
     if (version_compare(phpversion(), '5.4', '<')) {
         $this->_query->store_result();
     }
     call_user_func_array(array($this->_query, 'bind_result'), $parameters);
     while ($this->_query->fetch()) {
         $x = array();
         foreach ($row as $key => $val) {
             $x[$key] = $val;
         }
         array_push($results, $x);
     }
     $this->_last_result = $results;
 }
开发者ID:NightWingStudios,项目名称:Nightshade,代码行数:26,代码来源:Query.php

示例11: execute

 /**
  * Execute
  *
  * @param  null|array|Parameters $parameters
  * @throws Exception\RuntimeException
  * @return Result
  */
 public function execute($parameters = null)
 {
     if (!$this->isPrepared) {
         $this->prepare();
     }
     if (!$this->parameters instanceof Parameters) {
         if ($parameters instanceof Parameters) {
             $this->parameters = $parameters;
             $parameters = null;
         } else {
             $this->parameters = new Parameters();
         }
     }
     if (is_array($parameters)) {
         $this->parameters->setFromArray($parameters);
     }
     if ($this->parameters->count() > 0) {
         $this->bindParameters();
     }
     $return = $this->resource->execute();
     if ($return === false) {
         if (in_array($this->resource->errno, array(1060, 1061, 1062))) {
             throw new Exception\DuplicateException($this->resource->error, $this->resource->errno);
         }
         throw new Exception\RuntimeException($this->resource->error);
     }
     if ($this->bufferResults === true) {
         $this->resource->store_result();
         $this->isPrepared = false;
         $buffered = true;
     } else {
         $buffered = false;
     }
     $result = $this->driver->createResult($this->resource, $buffered);
     return $result;
 }
开发者ID:xudianyang,项目名称:yafrk-lib,代码行数:43,代码来源:Statement.php

示例12: _execute

 /**
  * Executes the specified MySQLi statement, stores the result and resets the
  * cache for things like where clauses, etc
  *
  * @param mysqli_stmt $statement The MySQLi statement that was prepared and is
  *  now ready to be executed
  */
 protected static function _execute($statement)
 {
     $statement->execute();
     $statement->store_result();
     self::_reset_cache();
 }
开发者ID:jugglinmike,项目名称:ae-framework,代码行数:13,代码来源:database.php

示例13: 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

示例14: _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

示例15: _dynamicBindResults

 protected 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];
     }
     if (version_compare(phpversion(), '5.4', '<')) {
         $stmt->store_result();
     }
     call_user_func_array(array($stmt, 'bind_result'), $parameters);
     $this->totalCount = 0;
     $this->count = 0;
     while ($stmt->fetch()) {
         $x = array();
         foreach ($row as $key => $val) {
             $x[$key] = $val;
         }
         $this->count++;
         array_push($results, $x);
     }
     if ($this->_mysqli->more_results()) {
         $this->_mysqli->next_result();
     }
     if ($this->fetchTotalCount === true) {
         $this->fetchTotalCount = false;
         $stmt = $this->_mysqli->query('SELECT FOUND_ROWS();');
         $totalCount = $stmt->fetch_row();
         $this->totalCount = $totalCount[0];
     }
     return $results;
 }
开发者ID:noikiy,项目名称:shopnc-minion,代码行数:38,代码来源:remoteDb.php


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