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


PHP mysqli_result::fetch方法代码示例

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


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

示例1: loadDataFromMysqliStatement

 /**
  * Mysqli's binding and returning of statement values
  * Mysqli requires you to bind variables to the extension in order to
  * get data out.  These values have to be references:
  *
  * @see http://php.net/manual/en/mysqli-stmt.bind-result.php
  * @throws Exception\RuntimeException
  * @return bool
  */
 protected function loadDataFromMysqliStatement()
 {
     $data = null;
     // build the default reference based bind structure, if it does not already exist
     if ($this->statementBindValues['keys'] === null) {
         $this->statementBindValues['keys'] = array();
         /* @var $resultResource \mysqli_result */
         $resultResource = $this->resource->result_metadata();
         foreach ($resultResource->fetch_fields() as $col) {
             $this->statementBindValues['keys'][] = $col->name;
         }
         $this->statementBindValues['values'] = array_fill(0, count($this->statementBindValues['keys']), null);
         $refs = array();
         foreach ($this->statementBindValues['values'] as $i => &$f) {
             $refs[$i] =& $f;
         }
         call_user_func_array(array($this->resource, 'bind_result'), $this->statementBindValues['values']);
     }
     if (($r = $this->resource->fetch()) === null) {
         if (!$this->isBuffered) {
             $this->resource->close();
         }
         return false;
     } elseif ($r === false) {
         throw new Exception\RuntimeException($this->resource->error);
     }
     // dereference
     for ($i = 0, $count = count($this->statementBindValues['keys']); $i < $count; $i++) {
         $this->currentData[$this->statementBindValues['keys'][$i]] = $this->statementBindValues['values'][$i];
     }
     $this->currentComplete = true;
     $this->nextComplete = true;
     $this->position++;
     return true;
 }
开发者ID:musicsnap,项目名称:Yaf.Global.Library,代码行数:44,代码来源:Result.php

示例2: nextRow

 /**
  * Go to next row
  * @param mysqli_result|resource|PDOStatement $result
  * @return array
  */
 public function nextRow($result)
 {
     return $result->fetch(PDO::FETCH_ASSOC);
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:9,代码来源:LudoDBPDOOracle.php

示例3: radioButtons

 /**
  * Build a radio button group from a set of $data with a specified $name, set the selected
  * radio button in the group if there is a match found between $selectedValue and button_value.
  *
  * If passing a \mysqli_result it must contain fields named as:
  *  - button_value 
  *  - button_text
  *
  *
  * @param Array|\mysqli_result $data The data to be used to build the radio button group. 
  * @param string $name The name of the radio button group.
  * @param mixed $selectedValue The option_value to set as checked.
  *
  * @return string
  */
 public function radioButtons($data, $name, $selectedValue = null)
 {
     $buttons = '';
     if ($data instanceof \PDOStatement) {
         while ($row = $data->fetch()) {
             $opts = array('name' => $name, 'value' => $row['button_value'], 'type' => 'radio');
             if ($row['button_value'] == $selectedValue) {
                 $opts['checked'] = 'checked';
             }
             //if
             $button = $this->app['Html']->input($opts);
             $buttons .= $this->app['Html']->label($row['button_text'] . $button);
         }
         //while
     } else {
         if (is_array($data)) {
             foreach ($data as $k => $v) {
                 $opts = array('name' => $name, 'value' => $k, 'type' => 'radio');
                 if ($k == $selectedValue) {
                     $opts['checked'] = 'checked';
                 }
                 //if
                 $button = $this->app['Html']->input($opts);
                 $buttons .= $this->app['Html']->label($v . $button);
             }
             //foreach
         } else {
         }
     }
     //el
     return $buttons;
 }
开发者ID:discophp,项目名称:framework,代码行数:47,代码来源:Form.class.php


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