本文整理汇总了PHP中mysqli_result::fetch_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_result::fetch_fields方法的具体用法?PHP mysqli_result::fetch_fields怎么用?PHP mysqli_result::fetch_fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli_result
的用法示例。
在下文中一共展示了mysqli_result::fetch_fields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Connection $connection
* @param null|\mysqli_result $result
*/
public function __construct(Connection $connection, $result = null)
{
$this->connection = $connection;
if ($result instanceof \mysqli_result) {
$this->result = $result;
$this->num_rows = $this->result->num_rows;
$this->fields = $this->result->fetch_fields();
} else {
$this->affected_rows = $this->getMysqliConnection()->affected_rows;
}
}
示例2: getFields
/**
* Returns an array of fields according to columns in the result.
*
* @return \Bitrix\Main\Entity\ScalarField[]
*/
public function getFields()
{
if ($this->resultFields == null) {
$this->resultFields = array();
if (is_object($this->resource)) {
$fields = $this->resource->fetch_fields();
if ($fields && $this->connection) {
$helper = $this->connection->getSqlHelper();
foreach ($fields as $field) {
$this->resultFields[$field->name] = $helper->getFieldByColumnType($field->name, $field->type);
}
}
}
}
return $this->resultFields;
}
示例3: 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;
}
示例4: fetchFieldProperties
/**
* Return properties taken from result fields as array(props, default props)
*
* @return array
*/
protected function fetchFieldProperties()
{
foreach ($this->native->fetch_fields() as $i => $field) {
$props[] = $this->convertFieldProperties($field, $i);
}
return $props;
}
示例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: displayRecords
/**
* Purpose: Display the results of a database query in an HTML table
* @param mysqli_result $qryResults Results of a previous database query
*/
public static function displayRecords($qryResults)
{
// Display the opening table tag
echo "<table>\n";
// Display a table row opening tag
echo " <tr>";
// LOOP for all query result columns
foreach ($qryResults->fetch_fields() as $fieldInfo) {
// Display the column name within a table header tag
echo "<th>{$fieldInfo->name}</th>";
}
// Display a table row closing tag
echo "</tr>\n";
// LOOP for all the query rows returned
while ($row = $qryResults->fetch_row()) {
// Display a table row opening tag
echo " <tr>";
// LOOP for all the query result columns
for ($i = 0; $i < $qryResults->field_count; $i++) {
// Display the value of this query result row and column
echo "<td>" . htmlspecialchars($row[$i]) . "</td>";
// $row[$i] = htmlspecialchars( $row[$i] );
// echo "<td>{$row[$i]}</td>";
}
// Display a table row closing tag
echo " </tr>\n";
}
// Display the closing table tag
echo "</table>\n";
}