本文整理汇总了PHP中mysqli_result::fetch_all方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_result::fetch_all方法的具体用法?PHP mysqli_result::fetch_all怎么用?PHP mysqli_result::fetch_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli_result
的用法示例。
在下文中一共展示了mysqli_result::fetch_all方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchAll
/**
* @param integer $fetchType
* @throws Recipe_Exception_Sql
* @return array|mixed
*/
public function fetchAll($fetchType = null)
{
if ($fetchType === null) {
$fetchType = self::DEFAULT_FETCH_TYPE;
}
return $this->result->fetch_all($fetchType);
}
示例2: fetchAllNum
/**
* Fetches all the rows as an array of indexed arrays
*
* @return array|mixed|null
*/
public function fetchAllNum()
{
if ($this->stored !== null) {
return $this->stored;
}
return $this->result->fetch_all(MYSQLI_NUM);
}
示例3: fetchAll
/**
* 获取所有结果
*
* @return array|mixed|null
*/
public function fetchAll()
{
$this->getResult();
if ($this->result) {
$this->mysql->num_rows = $this->result->num_rows;
if (method_exists($this->result, 'fetch_all')) {
$data = $this->result->fetch_all(MYSQLI_ASSOC);
} else {
$data = array();
while ($row = $this->result->fetch_assoc()) {
$data[] = $row;
}
}
return $data;
} else {
return null;
}
}
示例4: 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;
}
示例5: fetch
public function fetch()
{
if (!$this->_cursor) {
return null;
}
$res = array();
if (method_exists('mysqli_result', 'fetch_all')) {
$res = $this->_cursor->fetch_all(MYSQL_ASSOC);
} else {
while ($tmp = $this->_cursor->fetch_array(MYSQL_ASSOC)) {
$res[] = $tmp;
}
}
return $res;
}
示例6: _fetch_all
/**
* 将sql查询结果全部转化成数组
*
* @param \mysqli_result $res 要转化的查询
* @return array 查询的结果
*/
protected function _fetch_all($res)
{
if (method_exists('mysqli_result', 'fetch_all')) {
$data = $res->fetch_all(MYSQLI_ASSOC);
} else {
for ($data = []; $tmp = $res->fetch_array(MYSQLI_ASSOC);) {
$data[] = $tmp;
}
}
return $data;
}
示例7: fetchAll
/**
* Fetches all result rows and returns the result set as an associative array, a numeric array, or both.
* @param int $resultType MYSQLI_ASSOC, MYSQLI_NUM or MYSQLI_BOTH
* @return mixed
*/
public function fetchAll($resultType = MYSQLI_ASSOC)
{
return $this->query->fetch_all($resultType);
}
示例8: getAll
/**
* Returns the values of all rows.
* CAUTION: resets the result pointer.
*
* {@internal Mind the performance: not ifs in while loop}}
*
* @param int $resulttype A DB_Result::FETCH::% constant
* @param boolean $map Add mapping for roles
* @return array
*/
function getAll($resulttype = DB::FETCH_ORDERED)
{
if ($resulttype == DB::FETCH_VALUE) {
return $this->getColumn();
}
$key_field = $this->getFieldIndex('result:key');
$rows = array();
$this->native->data_seek(0);
$opt = $resulttype & ~0xff;
if (isset($key_field)) {
switch ($resulttype & 0xff) {
case DB::FETCH_ORDERED:
while ($row = $this->native->fetch_row()) {
$rows[$row[$key_field]] = $row;
}
break;
case DB::FETCH_ASSOC:
while ($row = $this->native->fetch_assoc()) {
$rows[$row['result:key']] = $row;
}
break;
case DB::FETCH_FULLARRAY:
while ($row = $this->native->fetch_array()) {
$rows[$row[$key_field]] = $row;
}
break;
case DB::FETCH_OBJECT:
while ($row = $this->native->fetch_object()) {
$rows[$row->{'result:key'}] = $row;
}
break;
default:
while ($row = $this->fetchRow($resulttype)) {
$rows[] = $row;
}
if (!empty($rows)) {
$rows = array_combine($this->getColumn($key_field), $rows);
}
break;
}
} else {
switch ($resulttype & 0xff) {
case DB::FETCH_ORDERED:
if (function_exists('mysqli_fetch_all')) {
$rows = $this->native->fetch_all(MYSQLI_NUM);
} else {
while ($row = $this->native->fetch_row()) {
$rows[] = $row;
}
}
break;
case DB::FETCH_ASSOC:
if (function_exists('mysqli_fetch_all')) {
$rows = $this->native->fetch_all(MYSQLI_ASSOC);
} else {
while ($row = $this->native->fetch_assoc()) {
$rows[] = $row;
}
}
break;
case DB::FETCH_OBJECT:
while ($row = $this->native->fetch_object()) {
$rows[] = $row;
}
break;
case DB::FETCH_FULLARRAY:
if (function_exists('mysqli_fetch_all')) {
$rows = $this->native->fetch_all(MYSQLI_BOTH);
} else {
while ($row = $this->native->fetch_array()) {
$rows[] = $row;
}
}
break;
case DB::FETCH_PERTABLE:
while ($row = $this->fetchPerTable($opt)) {
$rows[] = $row;
}
break;
case DB::FETCH_VALUE:
while ($row = $this->fetchValue(0, $opt)) {
$rows[] = $row;
}
break;
case DB::FETCH_RECORD:
while ($row = $this->fetchRecord($opt)) {
$rows[] = $row;
}
break;
case DB::FETCH_ROLES:
//.........这里部分代码省略.........
示例9: fetchAll
public function fetchAll()
{
return $this->result->fetch_all();
}