Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mysqli_result.field_count(3) [php 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)

Check Out this Related Man Page

MYSQLI_NUM_ROWS(3)							 1							MYSQLI_NUM_ROWS(3)

mysqli_result::$num_rows - Gets the number of rows in a result

       Object oriented style

SYNOPSIS
int$mysqli_result->num_rows () DESCRIPTION
Procedural style int mysqli_num_rows (mysqli_result $result) Returns the number of rows in the result set. The behaviour of mysqli_num_rows(3) depends on whether buffered or unbuffered result sets are being used. For unbuffered result sets, mysqli_num_rows(3) will not return the correct number of rows until all the rows in the result have been retrieved. 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
Returns number of rows in the result set. Note If the number of rows is greater than PHP_INT_MAX, the number will be returned as a string. 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 Code, Name FROM Country ORDER BY Name")) { /* determine number of rows result set */ $row_cnt = $result->num_rows; printf("Result set has %d rows. ", $row_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 Code, Name FROM Country ORDER BY Name")) { /* determine number of rows result set */ $row_cnt = mysqli_num_rows($result); printf("Result set has %d rows. ", $row_cnt); /* close result set */ mysqli_free_result($result); } /* close connection */ mysqli_close($link); ?> The above examples will output: Result set has 239 rows. SEE ALSO
mysqli_affected_rows(3), mysqli_store_result(3), mysqli_use_result(3), mysqli_query(3). PHP Documentation Group MYSQLI_NUM_ROWS(3)
Man Page