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

Discussion about the managed MySql extension [?] for Phalanger.

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

Postby kielsoft » June 3rd, 2011, 3:20 pm

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

kielsoft
 
Posts: 25
Joined: March 1st, 2012, 3:39 pm

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

Postby Jakub Misek » June 3rd, 2011, 3:42 pm

Hi,

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

Regards,
Jakub Misek 

Jakub Misek │ DEVSENSE s.r.o. │ Email: jakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2058
Joined: January 4th, 2012, 2:42 pm
Location: Prague

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

Postby kielsoft » June 7th, 2011, 9:53 am

@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.

kielsoft
 
Posts: 25
Joined: March 1st, 2012, 3:39 pm

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

Postby Jakub Misek » June 18th, 2013, 10:46 am

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.
Jakub Misek │ DEVSENSE s.r.o. │ Email: jakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2058
Joined: January 4th, 2012, 2:42 pm
Location: Prague


Return to MySql Extension project

Who is online

Users browsing this forum: No registered users and 3 guests

cron

User Control Panel

Login

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests (based on users active over the past 5 minutes)
Most users ever online was 62 on January 7th, 2012, 10:54 pm

Users browsing this forum: No registered users and 3 guests
Phalanger