doukezi4576 2015-03-25 02:52
浏览 81

laravel pivot更新列含糊不清

Hi have a problem with an update function it says the column updated_at is ambigious and it is. how can I make the updated_at to product.updated_at. my error.

my call to update: $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)

  • 写回答

1条回答 默认 最新

  • duanhanzi8328 2015-03-25 03:42
    关注

    just add the following line to your product model

    const UPDATED_AT = "product.updated_at";

    & attribute_product model

    const UPDATED_AT = "attribute_product.updated_at";

    update your model updated_at to include table name.

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘