【发布时间】:2020-11-26 18:13:38
【问题描述】:
我正在尝试使用这段代码将数据保存到 postgres 数据库中的表中:
protected $table = 'measurements';
protected $fillable = ['Measurement_Id','Patient_Id', 'Sensor_Id','Measurement_Type'];
public function saveMeasurement($sensor_Id, $patient_Id, $measurement_type){
$measurement = new Measurement();
$measurement->Measurement_Id = Str::Uuid();
$measurement->Patient_Id = $patient_Id;
$measurement->Sensor_Id = $sensor_Id;
$measurement->Measurement_Type = $measurement_type;
try {
$measurement->save();
return "Measurement saved";
}
catch (Exception $e){
return $e;
}
但我收到此错误消息:
SQLSTATE[42703]:未定义列:7 错误:关系“测量”的列“id”不存在
当我查看发送到数据库的请求时,我看到我也在发送和 id:
(“Measurement_Id”、“Patient_Id”、“Sensor_Id”、“Measurement_Type”、“id”、“updated_at”、“created_at”)
我已尝试重新创建模型和迁移似乎都没有帮助。
【问题讨论】:
-
你在使用 postgres 吗?
-
@sta 是的,它是一个 postgres 数据库
-
是的,我的主键是 uuid @sta
-
在你的模型上添加这一行
$incrementing = false;
标签: php laravel postgresql