Page 1 of 1

How to detect a TINYINT/BOOLEAN Column of a query result

PostPosted: June 3rd, 2011, 3:20 pm
by kielsoft

How can I detect TINYINT or BOOLEAN field from a Query Result


RE: How to detect a TINYINT/BOOLEAN Column of a query result

PostPosted: June 3rd, 2011, 3:42 pm
by Jakub Misek

Hi,

http://php.net/manual/en/function.mysql-fetch-field.php look for the result value, the "type" field?

Regards,
Jakub Misek 


RE: How to detect a TINYINT/BOOLEAN Column of a query result

PostPosted: June 7th, 2011, 9:53 am
by kielsoft

@Jakub, thanks so much for your response, but what I mean is that how can I determine if a column is really a TINYINT, MySQL convert Boolean to Tinyint (1) automatically.

In mysql_fetch_field or mysql_fetch_type Tinyint and other numeric type column are returned as "int" type in normal php.

I am write a phalanger application that will create columns in DataDridView automatically according to the structure of result of a query and I want any field of the result with TINYINT in MySQL to form a grid column ofSystem.Boolean as it DataType so as to display CheckBox instead of a System.String column that will dislay ordinary text.

More so, I will like to participate by submitting simple projects as tutorials for new users to go through.

Hope to here from you soon,

Thanks.


Re: How to detect a TINYINT/BOOLEAN Column of a query result

PostPosted: June 18th, 2013, 10:46 am
by Jakub Misek
I afraid, in PHP you can just query the table description
Code: Select all
mysql_query("SHOW COLUMNS FROM $table")
or a similar query.

btw MySQL does not have Boolean, it only has TinyInt of size 1.