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


PHP mysqli_result::fetch_object方法代码示例

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


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

示例1: result

 public function result($a_type = null)
 {
     if (!$this->m_result or !$this->m_result instanceof mysqli_result) {
         return $this->m_result;
     }
     $r = array();
     do {
         $row = false;
         switch ($a_type) {
             default:
             case ZDatabase::RESULT_TYPE_NUM:
                 $row = $this->m_result->fetch_array(MYSQLI_NUM);
                 break;
             case ZDatabase::RESULT_TYPE_ASSOC:
                 $row = $this->m_result->fetch_array(MYSQLI_ASSOC);
                 break;
             case ZDatabase::RESULT_TYPE_BOTH:
                 $row = $this->m_result->fetch_array(MYSQLI_BOTH);
                 break;
             case ZDatabase::RESULT_TYPE_OBJECT:
                 $row = $this->m_result->fetch_object();
                 break;
             case ZDatabase::RESULT_TYPE_RAW:
                 return $this->m_result;
         }
         if (!$row) {
             break;
         }
         $r[] = $row;
     } while (1);
     return $r;
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:32,代码来源:mysqlidatabaseadapter.php

示例2: result

 public function result($a_type = null, $a_arg = null)
 {
     if (!$this->m_result) {
         return $this->m_result;
     }
     if ($this->m_result->num_rows() === false) {
         return false;
     }
     $r = array();
     do {
         $row = false;
         switch ($a_type) {
             default:
             case Zoombi_Database::RESULT_TYPE_NUM:
                 $row = $this->m_result->fetch_array(MYSQLI_NUM);
                 break;
             case Zoombi_Database::RESULT_TYPE_ASSOC:
                 $row = $this->m_result->fetch_array(MYSQLI_ASSOC);
                 break;
             case Zoombi_Database::RESULT_TYPE_BOTH:
                 $row = $this->m_result->fetch_array(MYSQLI_BOTH);
                 break;
             case Zoombi_Database::RESULT_TYPE_OBJECT:
                 $row = func_num_args() > 1 ? $this->m_result->fetch_object(func_get_arg(1)) : $this->m_result->fetch_object();
                 break;
             case Zoombi_Database::RESULT_TYPE_RAW:
                 return $this->m_result;
         }
         if (!$row) {
             break;
         }
         $r[] = $row;
     } while (1);
     return $r;
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:35,代码来源:mysqli.php

示例3: get_object

 /**
  * @en Get element from query result as an object
  * @ru Получить первую запись из ответа базы данных в виде объекта
  *
  * $database = new database(); # do not forget to declare defines before calling this class:
  *                             # > RUDE_DATABASE_USER
  *                             # > RUDE_DATABASE_PASS
  *                             # > RUDE_DATABASE_HOST
  *                             # > RUDE_DATABASE_NAME
  *
  * $database->query('SELECT * FROM users WHERE 1 = 1');
  *
  * $result = $database->get_object(); # stdClass Object
  *                                    # (
  *                                    #     [id] => 2
  *                                    #     [username] => manager
  *                                    #     [hash] => 0991b08461e5ce0ee0a038c104b5a6d3
  *                                    #     [salt] => nLpUwvzSpD5yoqXtqjvhtqwhJUsMFh8P
  *                                    #     [role_id] => 2
  *                                    # )
  *
  * @return mixed
  */
 public function get_object()
 {
     if ($object = $this->result->fetch_object()) {
         return $object;
     }
     return null;
 }
开发者ID:ThisNameWasFree,项目名称:rude-univ,代码行数:30,代码来源:rude-database.php

示例4: currentHHVM

 /**
  * Returns the current row of a result set under HHVM
  * The problem was fetch_object creates new instance of a given class,
  * and attaches resulted key/value pairs after the class was constructed.
  *
  * @return  mixed
  */
 private function currentHHVM()
 {
     if ($this->_as_object === TRUE or is_string($this->_as_object)) {
         if ($this->_reflect_class === NULL) {
             // Create reflection class of given classname or stdClass
             $this->_reflect_class = new ReflectionClass(is_string($this->_as_object) ? $this->_as_object : 'stdClass');
         }
         // Support ORM with loaded, when the class has __set and __construct if its ORM
         if ($this->_reflect_class->hasMethod('__set') === TRUE && $this->_reflect_class->hasMethod('__construct') === TRUE) {
             // Get row as associated array
             $row = $this->_result->fetch_assoc();
             // Get new instance without constructing it
             $object = $this->_reflect_class->newInstanceWithoutConstructor();
             foreach ($row as $column => $value) {
                 // Trigger the class setter
                 $object->__set($column, $value);
             }
             // Construct the class with no parameters
             $object->__construct(NULL);
             return $object;
         } elseif (is_string($this->_as_object)) {
             // Return an object of given class name
             return $this->_result->fetch_object($this->_as_object, (array) $this->_object_params);
         } else {
             // Return an stdClass
             return $this->_result->fetch_object();
         }
     }
     // Get row as associated array
     return $this->_result->fetch_assoc();
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:38,代码来源:Result.php

示例5: get_results

 /**
  * Get results
  * @return array
  */
 public function get_results()
 {
     $ret = array();
     if (is_object($this->result)) {
         while ($row = $this->result->fetch_object()) {
             $ret[] = $row;
         }
     }
     return $ret;
 }
开发者ID:mpeshev,项目名称:wp-db-driver,代码行数:14,代码来源:mysqli.php

示例6: get_record

 /**
  * Obtenemos un elemento del resultado.
  * @param int $type Tipo de retorno de los valores.
  * @param int|array $cast Cast a aplicar a los elementos.
  * @return mixed
  * @author Ignacio Daniel Rostagno <ignaciorostagno@vijona.com.ar>
  */
 public function get_record($type = Database_Query::FETCH_ASSOC, $cast = NULL)
 {
     // $this->next();
     switch ($type) {
         case Database_Query::FETCH_NUM:
             // Obtenemos el arreglo.
             $resultado = $this->query->fetch_array(MYSQLI_NUM);
             // Evitamos cast de consultas erroneas o vacias.
             if (!is_array($resultado)) {
                 return $resultado;
             }
             // Expandimos listado de cast.
             $cast = $this->expand_cast_list($cast, count($resultado));
             // Realizamos el cast.
             $c = count($resultado);
             for ($i = 0; $i < $c; $i++) {
                 $resultado[$i] = $this->cast_field($resultado[$i], $cast[$i]);
             }
             return $resultado;
         case Database_Query::FETCH_OBJ:
             // Obtenemos el objeto.
             $object = $this->query->fetch_object();
             // Evitamos cast de consultas erroneas o vacias.
             if (!is_object($object)) {
                 return $object;
             }
             // Expandimos la lista de cast.
             $cast = $this->expand_cast_list($cast, array_keys(get_object_vars($object)));
             // Realizamos el cast.
             foreach ($cast as $k => $v) {
                 $object->{$k} = $this->cast_field($object->{$k}, $v);
             }
             return $object;
         case Database_Query::FETCH_ASSOC:
         default:
             // Obtenemos el arreglo.
             $resultado = $this->query->fetch_array(MYSQLI_ASSOC);
             // Evitamos cast de consultas erroneas o vacias.
             if (!is_array($resultado)) {
                 return $resultado;
             }
             // Expandimos la lista de cast.
             $cast = $this->expand_cast_list($cast, array_keys($resultado));
             // Realizamos el cast.
             foreach ($cast as $k => $v) {
                 $resultado[$k] = $this->cast_field($resultado[$k], $v);
             }
             return $resultado;
     }
 }
开发者ID:4bs4,项目名称:marifa,代码行数:57,代码来源:query.php

示例7: fetch

 /**
  * Mendapatkan hasil eksekusi query
  *
  * @param   string  $limit  Jumlah pembatasan output
  * @return  mixed
  */
 public function fetch($limit = null)
 {
     if ($limit !== false) {
         $this->doLimit($limit);
     }
     $result = [];
     if ($this->_results) {
         // Lakukan perulangan dari hasil query
         while ($row = $this->_results->fetch_object()) {
             $result[] = $row;
         }
         $this->clear();
     }
     return $result;
 }
开发者ID:gaiius,项目名称:tokonlen,代码行数:21,代码来源:Db.php

示例8: queryRows

 public function queryRows($sql)
 {
     $aaData = array();
     if (!$sql) {
         return false;
     }
     if (!$this->real_query($sql)) {
         throw new exception($this->error, $this->errno);
     }
     $result = new mysqli_result($this);
     while ($row = $result->fetch_object()) {
         $aaData[] = $row;
     }
     return $aaData;
 }
开发者ID:HomelessCoder,项目名称:weedo,代码行数:15,代码来源:db_mysqli.php

示例9: display_results

function display_results(mysqli_result $res)
{
    // Table header:
    echo '<table class="tbl">
	<tr>
		<th>Host</th>
		<th>User</th>
	</tr>
';
    // Fetch and print all the records:
    while ($row = $res->fetch_object()) {
        echo '<tr>
			<td>' . $row->host . '</td>
			<td>' . $row->user . '</td>
		</tr>';
    }
    echo '</table>';
}
开发者ID:raynaldmo,项目名称:php-education,代码行数:18,代码来源:mysqli.php

示例10: rowGenerator

 /**
  * @param \mysqli_result $result
  * @param $returnMode
  * @return \Generator
  */
 public function rowGenerator(\mysqli_result $result, $returnMode)
 {
     switch ($returnMode) {
         case self::RETURN_TYPE_ASSOC:
             (yield $result->fetch_assoc());
             break;
         case self::RETURN_TYPE_NUM:
             (yield $result->fetch_array(MYSQLI_NUM));
             break;
         case self::RETURN_TYPE_BOTH:
             (yield $result->fetch_array(MYSQLI_BOTH));
             break;
         case self::RETURN_TYPE_MYSQLI_ROW:
             (yield $result->fetch_row());
             break;
         case self::RETURN_TYPE_OBJ:
             (yield $result->fetch_object());
             break;
         default:
             (yield $result->fetch_assoc());
             break;
     }
 }
开发者ID:chilimatic,项目名称:database-component,代码行数:28,代码来源:MySQLiConnectionAdapter.php

示例11: getObj

 /**
  * returns a row as object
  * 
  * @return stdClass
  */
 public function getObj()
 {
     $this->currentRecord = $this->ResultSet->fetch_object();
     return $this->currentRecord;
 }
开发者ID:arieh,项目名称:PHPancake_TreeForum,代码行数:10,代码来源:ResultsetWrapper.php

示例12: fetchObject

 /**
  * Returns an object of the current row or null if no more rows are in the result
  * @param null $className
  * @param array $params
  * @return object|\stdClass
  */
 public function fetchObject($className = null, array $params = null)
 {
     return $this->dbResult->fetch_object($className, $params);
 }
开发者ID:prepare4battle,项目名称:Ilch-2.0,代码行数:10,代码来源:Result.php

示例13: _fetchObjectList

 /**
  * 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;
 }
开发者ID:daodaoliang,项目名称:nooku-framework,代码行数:23,代码来源:mysqli.php

示例14: fetch_object

 /**
  * returns all results as object
  * @param \mysqli_result $result result of last executed query
  * @return mixed
  */
 public function fetch_object($result)
 {
     return $result->fetch_object();
 }
开发者ID:BlackyPanther,项目名称:SQL-Class,代码行数:9,代码来源:SQL.class.php

示例15: make_log_entries

 /**
  * Make log entries
  *
  * @param \mysqli_result $log_res
  * @param string $type
  * @return string $logdata
  * @author Mauri Kujala <contact@edtb.xyz>
  */
 public function make_log_entries($log_res, $type)
 {
     $this_system = "";
     $this_id = "";
     $i = 0;
     while ($obj = $log_res->fetch_object()) {
         if ($this_id != $obj->id) {
             $system_name = $obj->system_name == "" ? $obj->log_system_name : $obj->system_name;
             $log_station_name = $obj->station_name;
             $log_text = $obj->log_entry;
             $date = date_create($obj->stardate);
             $log_added = date_modify($date, "+1286 years");
             $distance = $obj->distance != "" ? number_format($obj->distance, 1) : "";
             if ($this_system != $system_name && $type != "general") {
                 $add = $distance != 0 ? " (distance " . $distance . " ly)" : "";
                 $sortable = "";
                 if ($i == 0 && $type != "log") {
                     $sssort = $this->get_sort("slog");
                     $sortable = '<span class="right">';
                     $sortable .= '<a href="/?slog_sort=' . $sssort . '" title="Sort by date asc/desc">';
                     $sortable .= '<img class="icon" src="/style/img/sort.png" alt="Sort" style="margin-right:0" />';
                     $sortable .= '</a></span>';
                 }
                 /**
                  * provide crosslinks to screenshot gallery, log page, etc
                  */
                 $l_crosslinks = System::crosslinks($system_name, true, false, false);
                 $logdata .= '<header><h2><img class="icon" src="/style/img/system_log.png" alt="log" />';
                 $logdata .= 'System log for <a href="/System?system_name=' . urlencode($system_name) . '">';
                 $logdata .= $system_name;
                 $logdata .= '</a>' . $l_crosslinks . $add . $sortable . '</h2></header>';
                 $logdata .= '<hr>';
             } elseif ($type == "general" && $i == 0) {
                 $gssort = $this->get_sort("glog");
                 $sortable = '<span class="right">';
                 $sortable .= '<a href="/?glog_sort=' . $gssort . '" title="Sort by date asc/desc">';
                 $sortable .= '<img class="icon" src="/style/img/sort.png" alt="Sort" style="margin-right:0" />';
                 $sortable .= '</a></span>';
                 $logdata .= '<header><h2><img class="icon" src="/style/img/log.png" alt="log" />Commander\'s Log' . $sortable . '</h2></header>';
                 $logdata .= '<hr>';
             }
             /**
              * get title icons
              */
             $title_icons = $this->title_icons($obj);
             $log_title = !empty($obj->title) ? '&nbsp;&ndash;&nbsp;' . $obj->title : "";
             $logdata .= '<h3>' . $title_icons;
             $logdata .= '<a href="javascript:void(0)" onclick="toggle_log_edit(\'' . $obj->id . '\')" style="color:inherit" title="Edit entry">';
             $logdata .= date_format($log_added, "j M Y, H:i");
             if (!empty($log_station_name)) {
                 $logdata .= '&nbsp;[Station: ' . htmlspecialchars($log_station_name) . ']';
             }
             $logdata .= $log_title;
             $logdata .= '</a></h3>';
             $logdata .= '<pre class="entriespre" style="margin-bottom:20px">';
             if (!empty($obj->audio)) {
                 $logdata .= $this->get_audio($obj);
             }
             $logdata .= $log_text;
             $logdata .= '</pre>';
         }
         $this_system = $system_name;
         $this_id = $obj->id;
         $i++;
     }
     return $logdata;
 }
开发者ID:DBnR1,项目名称:EDTB,代码行数:75,代码来源:MakeLog.php


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