In web development, you always encounter database-related operations. As a beginner, this is something that must be mastered. Here's a concrete analysis.
fields, in addition to field names, data types, and lengths, have other properties, such as whether the primary key, whether it is a foreign key, whether it is allowed to be empty, and so on. The PHP Get field property is available through the mysql_field_flags () function, which has the following syntax format:
String Mysql_field_flags (resource $result, int $field _offset)
The parameters involved in the above syntax are described below:
L Result:mysql_query () The result set returned after the function is executed.
L Field_offset: The offset of the field with a starting value of zero.
The sample code for the PHP Get field property using the Mysql_field_flags () function is as follows:
- < ? PHP
- $ Connection = mysql_connect ("localhost",
"Root", "root") or Die ("Connection Server failed");
- mysql_select_db ("Sunyang", $connection)
Or Die ("Select Database Failed");
- $ Query = "SELECT * FROM Employee" ;
- $ result = mysql_query ($query) or Die
("Query data Failed"); Execute Query
- Echo mysql_field_flags ($result, 0);
Properties of the first field
- echo " < BR > ";
- Echo Mysql_field_flags ($result, 1);
Properties of the second field
- echo " < BR > ";
- Echo Mysql_field_flags ($result, 2);
Properties of the third field
- Mysql_free_result ($result);
- Mysql_close ();
- ?>
These are the tips we've shared about PHP's getting field properties.
http://www.bkjia.com/PHPjc/445928.html www.bkjia.com true http://www.bkjia.com/PHPjc/445928.html techarticle In Web development, you always encounter database-related operations. As a beginner, this is something that must be mastered. The following is a detailed analysis of the field in addition to the field name 、...