Home>Article>Backend Development> Some summary and detailed introduction about php mysqli function (5)
Foreword: PHP is a programming language that is relatively easy to get started with, and PHP has a lot of built-in functions. Therefore, it is particularly important to understand and master these built-in functions. Next we will analyze some of the built-in functions of PHP.
I will continue to organize it for you in the future.
Recommended related PHP video tutorials://m.sbmmt.com/course/list/29/type/2.html
Understanding of phpMysqli functions :
1. What is php mysqli?
php mysqli = php nysqli improved
The mysqli function allows you to access the database server.
Notice! The mysqli extension is available for mysqli version 4.1.13 or newer.
2. How to use mysqli function?
If you want to use the mysqli function, you must add support for the mysqli extension when compiling php.
For more information about installation, please visit:http://www.php.net/manual/en/mysqli.installation.php
For details about running configuration Detailed information address:http://www.php.net/manual/en/mysqli.configuration.php
3. Introduction to php related functions
1,mysqli_fetch_array()
Function
Description: Fetch a row from the result set as a numeric number or associative array, or both.
Note: The field names returned by this function are strictly case-sensitive.
2,mysqli_fetch_assoc
Function
Description: Take a row from the result set as an associative array.
Note: The field names returned by this function are strictly case-sensitive.
3,mysqli_fetch_field_direct(result,fieldnr)
Function
The parameter fieldnr is required, and the field number is specified to be between 0 and the number of fields-1 between.
Description: Take the meta-data of a single field (column) from the result set and return it as an object.
Example:
name); echo "
"; printf("数据表:%s",$fieldinfo->table); echo "
"; printf("最大长度:%s",$fieldinfo->max_length); //释放结果集 mysqli_free_result($result); } //关闭连接 mysqli_close($conn); ?>
What should be noted here is that the return value is an object containing the definition information of the field. If there is no available information, false is returned. This return object has the following attributes.
>name
-Field name
>orgname
-Original field name (if the field has an alias specified)
>table
-The name of the table to which the field belongs
>orgtable
-The original table name (if an alias is specified)
> ;def
-The default value of the field
>max_length
-The maximum width of the field
>length
- The field width specified in the table definition
>charsetnr
-The character set number of the field
>flags
-The bit flags of the field
>type
- The data type used for the field
>decimals
- Integer field, the number of digits after the decimal point
4,mysqli_fetch_field()
Function
Description: Get the next field from the result set and return related information.
Example:
name); echo "
"; printf("数据表:%s",$fieldinfo->table); echo "
"; printf("最大长度:%s",$fieldinfo->max_length); //释放结果集 mysqli_free_result($result); } //关闭连接 mysqli_close($conn); ?>
The returned object properties are the same as above.
5,mysqli_fetch_fields()
Function
Description: Return an array of objects representing fields in the result set, and then output related information.
Object properties are the same as above.
The above are the functions introduced to you this time. I hope it will be helpful to you. Thanks!
Recommended related articles://m.sbmmt.com/php-weizijiaocheng-428673.html
The above is the detailed content of Some summary and detailed introduction about php mysqli function (5). For more information, please follow other related articles on the PHP Chinese website!