當前位置: 首頁>>代碼示例>>PHP>>正文


PHP mysqli_stmt::reset方法代碼示例

本文整理匯總了PHP中mysqli_stmt::reset方法的典型用法代碼示例。如果您正苦於以下問題:PHP mysqli_stmt::reset方法的具體用法?PHP mysqli_stmt::reset怎麽用?PHP mysqli_stmt::reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mysqli_stmt的用法示例。


在下文中一共展示了mysqli_stmt::reset方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fetch

 /**
  * Fetches a row from the result set.
  *
  * @param int $style  OPTIONAL Fetch mode for this fetch operation.
  * @param int $cursor OPTIONAL Absolute, relative, or other.
  * @param int $offset OPTIONAL Number for absolute or relative cursors.
  * @return mixed Array, object, or scalar depending on fetch mode.
  * @throws Zend_Db_Statement_Mysqli_Exception
  */
 public function fetch($style = null, $cursor = null, $offset = null)
 {
     if (!$this->_stmt) {
         return false;
     }
     // fetch the next result
     $retval = $this->_stmt->fetch();
     switch ($retval) {
         case null:
             // end of data
         // end of data
         case false:
             // error occurred
             $this->_stmt->reset();
             return $retval;
         default:
             // fallthrough
     }
     // make sure we have a fetch mode
     if ($style === null) {
         $style = $this->_fetchMode;
     }
     // dereference the result values, otherwise things like fetchAll()
     // return the same values for every entry (because of the reference).
     $values = array();
     foreach ($this->_values as $key => $val) {
         $values[] = $val;
     }
     $row = false;
     switch ($style) {
         case Zend_Db::FETCH_NUM:
             $row = $values;
             break;
         case Zend_Db::FETCH_ASSOC:
             $row = array_combine($this->_keys, $values);
             break;
         case Zend_Db::FETCH_BOTH:
             $assoc = array_combine($this->_keys, $values);
             $row = array_merge($values, $assoc);
             break;
         case Zend_Db::FETCH_OBJ:
             $row = (object) array_combine($this->_keys, $values);
             break;
         case Zend_Db::FETCH_BOUND:
             $assoc = array_combine($this->_keys, $values);
             $row = array_merge($values, $assoc);
             return $this->_fetchBound($row);
             break;
         default:
             /**
              * @see Zend_Db_Statement_Mysqli_Exception
              */
             require_once 'Zend/Db/Statement/Mysqli/Exception.php';
             throw new Zend_Db_Statement_Mysqli_Exception("Invalid fetch mode '{$style}' specified");
             break;
     }
     return $row;
 }
開發者ID:BackupTheBerlios,項目名稱:oos-svn,代碼行數:67,代碼來源:Mysqli.php

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

示例3: execute

 /**
  * Executes the prepared statement. If the prepared statement included parameter
  * markers, you must either:
  * <ul>
  * <li>call {@link \TYPO3\CMS\Core\Database\PreparedStatement::bindParam()} to bind PHP variables
  * to the parameter markers: bound variables pass their value as input</li>
  * <li>or pass an array of input-only parameter values</li>
  * </ul>
  *
  * $input_parameters behave as in {@link \TYPO3\CMS\Core\Database\PreparedStatement::bindParams()}
  * and work for both named parameters and question mark parameters.
  *
  * Example 1:
  * <code>
  * $statement = $GLOBALS['TYPO3_DB']->prepare_SELECTquery('*', 'bugs', 'reported_by = ? AND bug_status = ?');
  * $statement->execute(array('goofy', 'FIXED'));
  * </code>
  *
  * Example 2:
  * <code>
  * $statement = $GLOBALS['TYPO3_DB']->prepare_SELECTquery('*', 'bugs', 'reported_by = :nickname AND bug_status = :status');
  * $statement->execute(array(':nickname' => 'goofy', ':status' => 'FIXED'));
  * </code>
  *
  * @param array $input_parameters An array of values with as many elements as there are bound parameters in the SQL statement being executed. The PHP type of each array value will be used to decide which PARAM_* type to use (int, string, boolean, NULL), so make sure your variables are properly casted, if needed.
  * @return bool Returns TRUE on success or FALSE on failure.
  * @throws \InvalidArgumentException
  * @api
  */
 public function execute(array $input_parameters = array())
 {
     $parameterValues = $this->parameters;
     if (!empty($input_parameters)) {
         $parameterValues = array();
         foreach ($input_parameters as $key => $value) {
             $parameterValues[$key] = array('value' => $value, 'type' => $this->guessValueType($value));
         }
     }
     if ($this->statement !== NULL) {
         // The statement has already been executed, we try to reset it
         // for current run but will set it to NULL if it fails for some
         // reason, just as if it were the first run
         if (!@$this->statement->reset()) {
             $this->statement = NULL;
         }
     }
     if ($this->statement === NULL) {
         // The statement has never been executed so we prepare it and
         // store it for further reuse
         $query = $this->query;
         $precompiledQueryParts = $this->precompiledQueryParts;
         $this->convertNamedPlaceholdersToQuestionMarks($query, $parameterValues, $precompiledQueryParts);
         if (!empty($precompiledQueryParts)) {
             $query = implode('', $precompiledQueryParts['queryParts']);
         }
         $this->statement = $GLOBALS['TYPO3_DB']->prepare_PREPAREDquery($query, $precompiledQueryParts);
         if ($this->statement === NULL) {
             return FALSE;
         }
     }
     $combinedTypes = '';
     $values = array();
     foreach ($parameterValues as $parameterValue) {
         switch ($parameterValue['type']) {
             case self::PARAM_NULL:
                 $type = 's';
                 $value = NULL;
                 break;
             case self::PARAM_INT:
                 $type = 'i';
                 $value = (int) $parameterValue['value'];
                 break;
             case self::PARAM_STR:
                 $type = 's';
                 $value = $parameterValue['value'];
                 break;
             case self::PARAM_BOOL:
                 $type = 'i';
                 $value = $parameterValue['value'] ? 1 : 0;
                 break;
             default:
                 throw new \InvalidArgumentException(sprintf('Unknown type %s used for parameter %s.', $parameterValue['type'], $key), 1281859196);
         }
         $combinedTypes .= $type;
         $values[] = $value;
     }
     // ->bind_param requires second up to last arguments as references
     if (!empty($combinedTypes)) {
         $bindParamArguments = array();
         $bindParamArguments[] = $combinedTypes;
         $numberOfExtraParamArguments = count($values);
         for ($i = 0; $i < $numberOfExtraParamArguments; $i++) {
             $bindParamArguments[] =& $values[$i];
         }
         call_user_func_array(array($this->statement, 'bind_param'), $bindParamArguments);
     }
     $success = $this->statement->execute();
     // Store result
     if (!$success || $this->statement->store_result() === FALSE) {
         return FALSE;
//.........這裏部分代碼省略.........
開發者ID:plan2net,項目名稱:TYPO3.CMS,代碼行數:101,代碼來源:PreparedStatement.php


注:本文中的mysqli_stmt::reset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。