Will the next thinkphp operation MySQL database insert date type display 0000-00-00?

Source: Internet
Author: User

The top of the picture is the data to be inserted, and below is Getlastsql () gets the INSERT statement Dateline field value changed?

Reply content:

The top of the picture is the data to be inserted, and below is Getlastsql () gets the INSERT statement Dateline field value changed?

If you look at the dataline format in the database, TP will check the format of the field in the database and convert the data to the corresponding format when inserting the data.

if(!isset($this->options['bind'][':'.$key]) && isset($this->fields['_type'][$key])){            $fieldType = strtolower($this->fields['_type'][$key]);            if(false !== strpos($fieldType,'enum')){                // 支持ENUM类型优先检测            }elseif(false === strpos($fieldType,'bigint') && 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 as an int (10) type
High space efficiency and very flexible
The time conversion format can be converted in PHP.

The framework will format the data, since the framework is not appropriate that the native is good, to understand why it is necessary to see the framework of the source

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