Reputation: 119
While inserting the data this error is populating in error log:
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');
}
Upvotes: 0
Views: 82
Reputation: 57131
As your not setting date_modified
, unless you have a default value in the database, you need to add something like
'date_modified'=>FunctionsV3::dateNow(),
to the list of fields your setting.
Upvotes: 1
Reputation: 16436
You need to add default value for date_modified
to null. Or you have to pass this also at created time
$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']),
'date_modified'=>FunctionsV3::dateNow()
);
Upvotes: 1
Reputation: 851
Add an empty check for empty values and fill them with another value or you can do something like this :
ALTER TABLE yourTable MODIFY created datetime NULL DEFAULT '1970-01-02'
Setting default datetime.
Upvotes: 1