[英]laravel pivot update column ambigious
Hi have a problem with an update function it says the column updated_at is ambigious and it is. 您好,更新功能有问题,它说一列updated_at是模棱两可的。 how can I make the updated_at to product.updated_at. 我怎样才能将updated_at设置为product.updated_at。 my error. 我的错误。
my call to update: $product->attributes()->wherePivot('id', $attribute['id'])->update($input); 我的更新请求:$ product-> attributes()-> wherePivot('id',$ attribute ['id'])-> update($ input);
my error: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'updated_at' in field list is ambiguous (SQL: update attributes
inner join attribute_product
on attributes
. id
= attribute_product
. attribute_id
set sku
= TEST, model
= , attribute_product
. name
= Color, unitprice
= 10.00, sellprice
= 20.00, discount
= 0, active
= 0, ordering
= 1, updated_at
= 2015-03-25 02:44:01 where attribute_product
. product_id
= 1 and attribute_product
. id
= 1) 我的错误:SQLSTATE [23000]:完整性约束违规:1052列'的updated_at'在字段列表是不明确的(SQL:更新attributes
内部联接attribute_product
的attributes
。 id
= attribute_product
。 attribute_id
设置sku
= TEST, model
=, attribute_product
。 name
=色, unitprice
= 10.00, sellprice
= 20.00, discount
= 0, active
= 0, ordering
= 1, updated_at
= 2015年3月25日2点44分01秒,其中attribute_product
。 product_id
= 1和attribute_product
。 id
= 1)
just add the following line to your product model 只需将以下行添加到您的产品模型中
const UPDATED_AT = "product.updated_at";
& attribute_product model &attribute_产品模型
const UPDATED_AT = "attribute_product.updated_at";
update your model updated_at to include table name. 更新模型updated_at以包括表名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.