php - MySQL - 'field' doesn't have a default value -
im using laravel framework , gives error db
error message:
[2016-04-25 06:07:34] local.error: exception 'pdoexception' message 'sqlstate[hy000]: general error: 1364 field 'remarks' doesn't have default value' in ...
the field 'remarks' has default value of 'none' set in phpmyadmin. dont understand why gives error when has default value set. believe 'none' string value it's not null value.
$aid = db::table('attachments')->insertgetid([ 'document_type_code'=>$document_id, 'report_no'=>'report '.$document_id, 'file_attachment_link'=>$filepath, 'file_attachment_upload'=>$file->getclientoriginalname(), 'uploaded_at'=> $now, 'uploaded_by' => 1, //auth::user()->id 'version_number' => 1, ]);
none
not default string value. means there no default value set.
you can either pass value in insert
statement or alter table hold default value column.
you can use sql
statement alter table
alter table attachments modify column `remarks` varchar(255) default 'something';
or phpmyadmin
Comments
Post a Comment