MYSQLI_RESULT(3) 1 MYSQLI_RESULT(3)The mysqli_result classINTRODUCTION
Represents the result set obtained from a query against the database.
Changelog
Changelog
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.4.0 | |
| | |
| | Iterator support was added, as mysqli_result now |
| | implements Traversable. |
| | |
+--------+---------------------------------------------------+
CLASS SYNOPSIS
mysqli_result
mysqli_resultTraversable
Properties
o
int$mysqli_result->current_field
o
int$mysqli_result->field_count
o
array$mysqli_result->lengths
o
int$mysqli_result->num_rows
Methods
o
bool mysqli_result::data_seek (int $offset)
o
mixed mysqli_result::fetch_all ([int $resulttype = MYSQLI_NUM])
o
mixed mysqli_result::fetch_array ([int $resulttype = MYSQLI_BOTH])
o
array mysqli_result::fetch_assoc (void )
o
object mysqli_result::fetch_field_direct (int $fieldnr)
o
object mysqli_result::fetch_field (void )
o
array mysqli_result::fetch_fields (void )
o
object mysqli_result::fetch_object ([string $class_name], [array $params])
o
mixed mysqli_result::fetch_row (void )
o
bool mysqli_result::field_seek (int $fieldnr)
o
void mysqli_result::free (void )
PHP Documentation Group MYSQLI_RESULT(3)
Check Out this Related Man Page
MYSQLI_RESULT.FIELD_COUNT(3) 1 MYSQLI_RESULT.FIELD_COUNT(3)mysqli_result::$field_count - Get the number of fields in a result
Object oriented style
SYNOPSIS
int$mysqli_result->field_count ()
DESCRIPTION
Procedural style
int mysqli_num_fields (mysqli_result $result)
Returns the number of fields from specified result set.
PARAMETERS
o $
result -Procedural style only: A result set identifier returned by mysqli_query(3), mysqli_store_result(3) or
mysqli_use_result(3).
RETURN VALUES
The number of fields from a result set.
EXAMPLES
Example #1
Object oriented style
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}
if ($result = $mysqli->query("SELECT * FROM City ORDER BY ID LIMIT 1")) {
/* determine number of fields in result set */
$field_cnt = $result->field_count;
printf("Result set has %d fields.
", $field_cnt);
/* close result set */
$result->close();
}
/* close connection */
$mysqli->close();
?>
Example #2
Procedural style
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}
if ($result = mysqli_query($link, "SELECT * FROM City ORDER BY ID LIMIT 1")) {
/* determine number of fields in result set */
$field_cnt = mysqli_num_fields($result);
printf("Result set has %d fields.
", $field_cnt);
/* close result set */
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
The above examples will output:
Result set has 5 fields.
SEE ALSO mysqli_fetch_field(3).
PHP Documentation Group MYSQLI_RESULT.FIELD_COUNT(3)