gpt4 book ai didi

php - Eloquent 删除-SQLSTATE [22007] : Invalid datetime format: 1292 Truncated incorrect DOUBLE value:

转载 作者:行者123 更新时间:2023-11-29 02:10:40 24 4
gpt4 key购买 nike

我收到这个错误:

SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: '808498e7-a393-42f1-ab23-6ee89eb7040a' 

尝试通过关系删除记录时,使用:

$delivery->stockMovements()->delete();

原始查询显示为:

delete from `stock_movements` where `stock_movements`.`entity_id` = 10000005 and `stock_movements`.`entity_id` is not null and `stock_movements`.`company_id` = 8b11050c-612c-4922-8b34-d04d579e02a9

我搜索了又搜索,但找不到与此相关的任何内容,除了它可能与转换错误有关。也许与 UUID 有关?

迁移如下:

    Schema::create('deliveries', function (Blueprint $table) {
$table->increments('id');
$table->uuid('company_id');
$table->string('delivery_type');
$table->string('supplier_name');
$table->string('supplier_ref')->nullable();
$table->string('merchant_ref')->nullable();
$table->string('carrier_name')->nullable();
$table->string('status');
$table->date('expected_delivery');
$table->dateTime('completed_at')->nullable();
$table->timestamps();
});


Schema::create('stock_movements', function (Blueprint $table) {
$table->increments('id');
$table->uuid('company_id');
$table->uuid('product_id');
$table->string('entity_type'); //can be order / delivery
$table->string('entity_id'); //can be UUID / String / Integer
$table->string('location_id')->nullable(); // can be warehouse_location / shipment_package / delivery_container
$table->string('action')->default('');
$table->integer('qty')->default(0);
$table->timestamps();
});

最佳答案

我知道它已经几个月了,但由于没有公认的解决方案,我发布了我的解决方案。
我收到了完全相同的错误消息,但上下文略有不同:

Table::whereIn('fk_id', $arrayOfFkIds)
->delete();

该数组包含的值可以是字符串(如“ABC1234”,如您的 company_id)或整数。

解决方法是当我构建这个数组时,我将所有内容都转换为字符串:

$arrayOfFkIds[] = (string)$parsedArray['stuff_id'];

然后没有更多的 SQL 错误,一切顺利。

关于php - Eloquent 删除-SQLSTATE [22007] : Invalid datetime format: 1292 Truncated incorrect DOUBLE value:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53683774/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com