PHP MySQL Functions to get the flags of a field type from a result setBy using PHP PDO we can display all flags associated with the field or columns of a record. Here is the query
We will use PHP script to display all details of the columns.
This old MySQL extension was deprecated in PHP 5.5.0 and was removed in PHP 7
Use mysqli_fetch_field_direct() in place of mysql_field_flags(). mysql_field_flagsThis function is used to collect flags associated with a field in a table. It takes a result set and field offset value of the field and returns all the flags. Here all returned flags are separated by a single space so we can use explode function of PHP to create an array of flags. Here we will try to first display the flags of a field of student table and then we will use the same code to display the flags of all the fields. For this, we will first use mysql_fetch_field to list all the fields of a table and then we will try to use the mysql_field_flags function to display all the flags of those fields. Let us start with displaying the flags associated with the first field ( index=0 )
The above code will display the flags associated with the first field of the student table. Now we will try to improve the code and first list all the fields and then use the above code to display all the field flags associated with it.
The result of the above query is here id 0 -> not_null 1 -> primary_key 2 -> auto_increment name 0 -> not_null class 0 -> not_null mark 0 -> not_null The sql dump of student table is here. CREATE TABLE student ( id int(2) NOT NULL auto_increment, name varchar(50) NOT NULL default '', class varchar(10) NOT NULL default '', mark int(3) NOT NULL default '0', UNIQUE KEY id (id) ) TYPE=MyISAM; Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
![]() ![]() |