gpt4 book ai didi

php - Eloquent find(2) 返回错误记录

转载 作者:行者123 更新时间:2023-12-04 15:08:01 27 4
gpt4 key购买 nike

$wire = Wire::find(2)->value('选项');
var_dump($wire);
死();

返回string(39) "{"note": "wire one", "value": "WIRE 1"}

这是我的 2 个数据库条目。

1   {"note": "wire one", "value": "WIRE 1"} WIRE ONE    2017-01-29 01:37:49 2017-01-29 01:37:49
2 {"note": "wire two", "value": "WIRE 2"} WIRE TWO 2017-01-29 01:38:19 2017-01-29 01:38:19

为什么 find(2) 返回记录 #1 的值?

我在另一个 Laravel 应用程序中认识到了这一点。这是在新的 Laravel 应用程序中完成的。

最佳答案

看起来像是用 ->value 或 ->get 来详细说明 find() 方法,运行一个全新的查询。

Wire::find(2)->get(); 运行检索所有模型的新查询。

Wire::find(2); 按主键 2 返回模型。

关于php - Eloquent find(2) 返回错误记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41916845/

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