gpt4 book ai didi

php - 插入数据时,此错误会填充到错误日志中

转载 作者:太空宇宙 更新时间:2023-11-03 11:36:52 26 4
gpt4 key购买 nike

插入数据时,错误日志中会出现此错误:

PHP Fatal error: Uncaught CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'date_modified' at row 1 in /var/www/html/yiiframework/db/CDbCommand.php:358

            $p = new CHtmlPurifier();

$params=array(
'first_name'=>$p->purify($this->data['first_name']),
'last_name'=>$p->purify($this->data['last_name']),
'email_address'=>$p->purify($this->data['email_address']),
'password'=>md5($this->data['password']),
'date_created'=>FunctionsV3::dateNow(),
'ip_address'=>$_SERVER['REMOTE_ADDR'],
'contact_phone'=>$p->purify($this->data['contact_phone'])
);

public static function dateNow()
{
return date('Y-m-d G:i:s');
}

最佳答案

为空值添加空检查并用另一个值填充它们,或者您可以这样做:

ALTER TABLE yourTable MODIFY created datetime NULL DEFAULT '1970-01-02'

设置默认日期时间。

关于php - 插入数据时,此错误会填充到错误日志中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45182494/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com