【发布时间】:2021-02-28 12:31:34
【问题描述】:
我没有使用迁移文件,因为我在数据库中有预先存在的表,我想知道如何强制 laravel 使用我的复合主键。如果有任何方法可以覆盖。 复合主键为(Tel + number_str) 这是我在模型中的功能:
public function saveData(){
$response = new ResponseModel();
//Primary key(Tel + number_str )
$reponse->Tel = '0123456789';//---> the first key
$reponse->number_str = '1'; //---> the second key
$reponse->view = '0';
$reponse->channal = '0';
$reponse->save();
}
当我执行时出现此错误:
Yajra\Pdo\Oci8\Exceptions\Oci8Exception
Error Code : 904
Error Message : ORA-00904: "ID": invalid identifier Position : 98 Statement : insert into "RESPONSE" ("TEL", "number_str", "view", "channal ") values (:p0, :p1, :p2, :p3) returning "ID" into :p4 Bindings : [0123456789,1,0,0,0]
【问题讨论】:
-
这是什么,
laravel-5或laravel-8? "insert into "REPONSE"" 是错字还是REPONSE正确? -
这是响应,对不起。
-
是否有任何方法可以在 laravel 8 中覆盖以允许我使用复合键?
标签: laravel web laravel-5 eloquent laravel-8