Could you tell me the Thinkphp operation mysql database insert date type display 0000-00-00?

Source: Internet
Author: User
The data to be inserted is on the top of the image, and the value of the dateline Field Obtained by getLastsql () has changed?

The data to be inserted is on the top of the image, and the value of the dateline Field Obtained by getLastsql () has changed?

Reply content:

The data to be inserted is on the top of the image, and the value of the dateline Field Obtained by getLastsql () has changed?

Take a look at the dataline format in the database. When you insert data, TP checks the format of the field in the database and converts the data to the corresponding format.

If (! Isset ($ this-> options ['bind'] [':'. $ key]) & isset ($ this-> fields ['_ type'] [$ key]) {$ fieldType = strtolower ($ this-> fields ['_ type'] [$ key]); if (false! = Strpos ($ fieldType, 'enum') {// supports enum type priority detection} elseif (false === strpos ($ fieldType, 'bigint') & amp; false! = Strpos ($ fieldType, 'int') {$ data [$ key] = intval ($ data [$ key]);} elseif (false! = Strpos ($ fieldType, 'float') | false! = Strpos ($ fieldType, 'double') {$ data [$ key] = floatval ($ data [$ key]);} elseif (false! = Strpos ($ fieldType, 'bool ') {$ data [$ key] = (bool) $ data [$ key] ;}}

And the length of the database Field definition.

First, the data inventory time field is recommended to be of the int (10) type.
High space efficiency and flexibility
The time conversion format can be converted in php.

The framework will format the data. Since the framework is not suitable, it will be native. To understand the source code of the framework, we have to look at it.

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.