Question about querying mysql in php

Source: Internet
Author: User
Question about querying mysql in php I used php to check some data from mysql,
However, I want to know the data type of these fields. how can this problem be solved,
I don't know what the SQL statement is like or whether it is uncertain. it may be that multiple tables or fields are also calculated.
It cannot be obtained through the lookup table field.
Is there a way? I like C # in this regard. I don't want to manage any types of SQL data.
Answer


Reply to discussion (solution)

Mysql_field_type -- specify the field type in the result set
Mysql_field_table -- get the name of the table where the specified field is located

Php is a weak type language, and the actual data type is no longer so important.

Mysql_field_type -- specify the field type in the result set
Mysql_field_table -- get the name of the table where the specified field is located



Thanks, it is indeed available, but there is a problem when SQL is in progress. This field is calculated and returns the real type, which is obviously incorrect,

For example, select a + B from t
.
This will not be a problem in c.

Real occurs because a and B have different types.

Double precision [(M, D)] [UNSIGNED] [ZEROFILL], REAL [(M, D)] [UNSIGNED] [ZEROFILL]

Is a synonym of DOUBLE. Except: If the SQL Server mode includes the REAL_AS_FLOAT option, REAL is a synonym for FLOAT, not a synonym for DOUBLE.

Real number
What's wrong?

Real number
What's wrong?



I mainly want to get the flaot, int, and double types. I don't know how real is classified.

Because my requirement here is that the user writes an SQL statement to get the result, and I need to use the type for display.


Real number
What's wrong?



I mainly want to get the flaot, int, and double types. I don't know how real is classified.

Because my requirement here is that the user writes an SQL statement to get the result, and I need to use the type for display.



Or can real be classified as numbers?

Real? Double.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.