本文整理汇总了PHP中mysqli_result类的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_result类的具体用法?PHP mysqli_result怎么用?PHP mysqli_result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_result类的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;
}
示例2: 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;
}
示例3: 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;
}
示例4: close
/**
*
* 关闭 stmt result mysqli的函数,传入这三个东西就行
* @param mysqli,stmt,result
*/
static function close(mysqli $mysqli = null, mysqli_stmt $stmt = null, mysqli_result $result = null)
{
if ($result != null) {
$result->free();
}
if ($stmt != null) {
$stmt->close();
}
if ($mysqli != null) {
$mysqli->close();
}
}
示例5: fetchResource
/**
* @param \mysqli_result $resource
* @param string $column
*
* @return mixed[]
*/
protected function fetchResource($resource, $column)
{
$fields = $resource->fetch_fields();
if (count($fields) == 0) {
return [];
}
$result = $resource->fetch_all(MYSQLI_ASSOC);
if (!is_array($result)) {
return [];
}
$resource->free();
$this->fixTypes($result, $fields, $column);
return $result;
}
示例6: 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;
}
}
}
}
}
示例7: 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;
}
}
}
}
}
示例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;
}
示例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>';
}
示例10: rewind
/**
* Rewind
*
*/
public function rewind()
{
$this->currentComplete = false;
$this->position = 0;
if ($this->resource instanceof \mysqli_stmt) {
//$this->resource->reset();
} else {
$this->resource->data_seek(0);
// works for both mysqli_result & mysqli_stmt
}
}
示例11: rewind
/**
* Rewind
*/
public function rewind()
{
if ($this->position !== 0) {
if ($this->isBuffered === false) {
throw new Exception\RuntimeException('Unbuffered results cannot be rewound for multiple iterations');
}
}
$this->resource->data_seek(0); // works for both mysqli_result & mysqli_stmt
$this->currentComplete = false;
$this->position = 0;
}
示例12: fetch
/**
* Извлечение данных
*
* @return array|null
*/
protected function fetch()
{
if (!$this->isValidResult()) {
return null;
}
return $this->query_result->fetch_array($this->fetch_type);
}
示例13: Close
/**
* (non-PHPdoc)
* @see Phine/Framework/Database/Interfaces/IDatabaseReader#Close()
*/
function Close()
{
if (!$this->IsClosed()) {
$this->result->close();
$this->closed = true;
}
}
示例14: freeResult
/**
* Очищение результатов
*/
protected function freeResult()
{
if ($this->query_result !== null) {
$this->query_result->free_result();
$this->query_result = null;
}
$this->result = null;
}
示例15: nextRecord
public function nextRecord()
{
if (is_object($this->handle) && ($data = $this->handle->fetch_assoc())) {
return $data;
} else {
return false;
}
}