$model = Test::first();
$model->status = 2;
$model->save();
If the Test model does not have an ID field in the corresponding table, an error will be reported
Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘id’ in ‘where clause’ (SQL: update test set status = 2, test.updated_at = 2020-09-04 15:03:06 where id is null) in file D:\www\wb-mg\vendor\laravel\framework\src\Illuminate\Database\Connection.php on line 671
As you can see above, save()
is to match the updated data through the id
field, so don’t use save()
if the table doesn’t have an ID field.
Read More:
- DataTables warning encountered using DataTables: table id = DataTables_Table_0 – Ajax error. For more information ab
- [Solved] Laravel Create Data Table Error: Syntax error or access violation: 1071 Specified key was too long
- [Solved] laravel Project Deploy Error: No input file specified.
- [Solved] Faceswap Error: CRITICAL An unexpected crash has occurred.You MUST provide this file if seeking assistan
- Json: struct field readyReplicas has json tag but is not exported [How to Solve]
- Doris BrokerLoad Error: No source file in this table [How to Solve]
- [How to Solve] canvas.save(Canvas.ALL_SAVE_FLAG)
- [Solved] Laravel reports an error when executing composer update
- [Solved] volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
- [Solved] Error: The superclass, ‘Animal‘, has no unnamed constructor that takes no arguments.
- laravel Error mews/captcha is locked to version 3.2.4 and an update of this package was not requested.
- laravel-echo-server Run Error: [ioredis] Unhandled error event: ReplyError: NOAUTH Authentication required.
- Vitis-AI Generate a Quantitative Model: NotImplementedError
- [Solved] This application has no explicit mapping for /error, so you are seeing this as a fallback
- [Jeston Xavier NX Compile librealsense Error] AttributeError: module ‘pyrealsense2‘ has no attribute ‘pipeline‘
- How to Solve Keras calls plot_model error
- Peewee insert data error:’buffer’ object has no attribute’translate’
- IText The document has no pages [How to Solve]
- Mysql5.7.18.1 Error 1054 (42S22): Unknown Column’password’ In’field List’ When Changing User Password
- Download and save uniapp pictures to Android error reporting app