本文整理汇总了PHP中mysqli_result::fetch_assoc方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_result::fetch_assoc方法的具体用法?PHP mysqli_result::fetch_assoc怎么用?PHP mysqli_result::fetch_assoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli_result
的用法示例。
在下文中一共展示了mysqli_result::fetch_assoc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
/**
* @param mysqli_result $mysqli_result
* @param bool $single
* @return array|bool|null
*/
public function fetch($mysqli_result, $single)
{
$this->_('fields', array());
foreach ($mysqli_result->fetch_fields() as $field) {
$this->_('fields')[$field->name] = $this->rules[$this->types[$field->type]];
}
switch (true) {
case !$mysqli_result:
return null;
case $single && $mysqli_result->num_rows == 0:
$result = false;
break;
case $single:
$result = $this->cast($mysqli_result->fetch_assoc());
break;
case $mysqli_result->num_rows == 0:
$result = array();
break;
default:
$result = array();
while ($row = $mysqli_result->fetch_assoc()) {
$result[] = $this->cast($row);
}
}
$mysqli_result->free();
return $result;
}
示例2: fetch
/**
* @return array|null
*/
public function fetch()
{
if (is_bool($this->result)) {
return $this->result;
}
return $this->result->fetch_assoc();
}
示例3: fetch_accoc
public function fetch_accoc()
{
while ($row = $this->resource_id->fetch_assoc()) {
$this->result_array[] = $row;
}
return $this->result_array;
}
示例4: nextRecord
public function nextRecord()
{
if (is_object($this->handle) && ($data = $this->handle->fetch_assoc())) {
return $data;
} else {
return false;
}
}
示例5: fetchAll
function fetchAll()
{
$data = array();
while ($record = $this->result->fetch_assoc()) {
$data[] = $record;
}
return $data;
}
示例6: fetch
/**
* @param Entity $entity
* @return EntityManagerMysqli
*/
protected function fetch(\mysqli_result $result, Entity $entity = null)
{
while ($data = $result->fetch_assoc()) {
$this->add($entity->getClone()->serialize($data));
}
return $this;
}
示例7: 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();
}
示例8: loadFromMysqliResult
/**
* Load from mysqli result
*
* @return bool
*/
protected function loadFromMysqliResult()
{
$this->currentData = null;
if (($data = $this->resource->fetch_assoc()) === null) {
return false;
}
$this->position++;
$this->currentData = $data;
$this->currentComplete = true;
$this->nextComplete = true;
$this->position++;
return true;
}
示例9: loadDefaultData
function loadDefaultData($totalCount, mysqli_result $result)
{
if ($totalCount == 0) {
echo "暂无资讯";
return;
} else {
if ($totalCount > 0) {
$cnt = 0;
while ($row = $result->fetch_assoc()) {
if ($cnt < DEFAULT_SHOW) {
$list_id = $row["info_id"];
echo "<div class=\"list\">";
echo "<a href=\"" . $row["origin_link"] . "\" class=\"nav_list\" data-id={$list_id} onclick=\"count({$list_id})\">";
echo "<p class=\"caption\">";
echo $row["caption"];
echo "</p>";
echo "<p class=\"subhead\">";
echo $row["subhead"];
echo "</p>";
echo "<div class=\"footer\">";
echo "<span class=\"text_des\">";
echo $row["origin"];
echo "</span>";
echo " ";
echo " ";
echo "<span class=\"num_des\">";
echo substr($row["publish_date"], 5, 5);
echo "</span>";
echo " ";
echo " ";
echo "<div class=\"like\">";
echo "<img src=\"../images/grayheart.png\" class=\"icon\">";
echo "<span class=\"info_like\">";
echo showFavNum($row["fav"]);
echo "</span>";
echo "</div>";
echo "</div>";
echo "<img src=\"" . $row["pic_link"] . "\" class=\"show_pic\">";
echo "</a>";
echo "</div>";
echo "<hr/>";
$cnt++;
} else {
break;
return;
}
}
}
}
}
示例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;
}
}
示例11: loadDefaultData
function loadDefaultData($totalCount, mysqli_result $result)
{
if ($totalCount == 0) {
return;
} else {
if ($totalCount > 0) {
$cnt = 0;
while ($row = $result->fetch_assoc()) {
if ($cnt < DEFAULT_SHOW) {
$list_id = $row["info_id"];
echo "<div class=\"list\">";
echo "<a href=\"" . $row["origin_link"] . "\" class=\"e_wine_list\" data-id={$list_id} onclick=\"count({$list_id})\">";
echo "<p class=\"wine_caption\">";
echo $row["caption"];
echo "</p>";
echo "<p class='wine_subhead'>";
echo $row['subhead'];
echo "</p>";
echo "<div class=\"wine_footer\">";
echo "<span class=\"wine_orgin\">";
echo $row["origin"];
echo "</span>";
echo " ";
echo " ";
echo "<span class=\"wine_price\">";
echo $row["publish_date"];
echo "</span>";
echo " ";
echo " ";
echo "<div class=\"wine_fav\">";
echo "<img src=\"../images/grayheart.png\" class=\"icon\">";
echo "<span class=\"wine_fav_num\">";
echo showFavNum($row["fav"]);
echo "</span>";
echo "</div>";
echo "</div>";
echo "<img src=\"" . $row["pic_link"] . "\" class=\"wine_show_pic\">";
echo "</a>";
echo "</div>";
echo "<hr/>";
$cnt++;
} else {
break;
return;
}
}
}
}
}
示例12: loadMore
function loadMore($page, mysqli_result $result)
{
$pos = 0;
$cnt = 0;
$arry = array();
while ($row = $result->fetch_assoc()) {
if ($pos != $page * DEFAULT_SHOW) {
$pos++;
continue;
} else {
if ($cnt < DEFAULT_SHOW) {
array_push($arry, $row);
$cnt++;
} else {
break;
return;
}
}
}
return json_encode($arry, JSON_UNESCAPED_UNICODE);
}
示例13: one
/**
* @inheritdoc
*/
public function one()
{
return $this->result->fetch_assoc();
}
示例14: fetch_assoc
/**
* @param mysqli_result $query_id
* @return array|bool
*/
public function fetch_assoc($query_id)
{
return $query_id ? $query_id->fetch_assoc() : false;
}
示例15: loadDefaultComments
function loadDefaultComments($totalCount, mysqli_result $res)
{
if ($totalCount == 0) {
return;
} else {
$cnt = 0;
while ($row = $res->fetch_assoc()) {
if ($cnt < DEFAULT_SHOW) {
echo "<div class=\"conts\">";
echo "<div class=\"user_bar\">";
echo "<div class=\"user_info\">";
echo "<img src=\"" . $row["head_pic"] . "\">";
echo "<p class=\"uname\">";
echo $row["nickname"];
echo "</p>";
echo "<p class=\"date_time\">";
echo $row["create_time"];
echo "</p>";
echo "</div>";
echo "</div>";
echo "<div class=\"comment_info\">";
echo "<p class=\"comment_cont\">";
echo $row["comment_cont"];
echo "</p>";
echo "</div>";
echo "</div>";
echo "<hr/>";
$cnt++;
} else {
break;
return;
}
}
}
}