By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,061 Members | 1,523 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,061 IT Pros & Developers. It's quick & easy.

Extract integer from mysql via PHP

P: 41
mysql and mysqli functions always return strings values, and I understand that I can set the type of the data via the settype function AFTER I extract the data, but is there a way with PHP to extract the data as it is specified in the mysql database? (i.e if the type is an integer then PHP will insert the integer value in the result set).

The reason I ask is I want to create a function to verify the integrity of the database before I process it and if I can skip creating a function using regex to check if the value is an integer I would go that route.

Any help is appreciated
Dec 13 '07 #1
Share this Question
Share on Google+
2 Replies


100+
P: 105
Instead of extracting the data from the db and checking it, why dont you check the database itself?


try this : SHOW FULL COLUMNS FROM [YOUR TABLE]


more info:
http://dev.mysql.com/doc/refman/5.0/en/show-columns.html
Dec 15 '07 #2

P: 41
Instead of extracting the data from the db and checking it, why dont you check the database itself?


try this : SHOW FULL COLUMNS FROM [YOUR TABLE]


more info:
http://dev.mysql.com/doc/refman/5.0/en/show-columns.html
Good idea, Thanks man.

Now this question has turned into a MYSQL question.

Is it possible to do some simple data integrity checks using queries? For example checking to see if a particular column has only alphanumeric characters in its data, or something like that.
Dec 15 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.