FuelPHP ORM 通过数组更新

发布于 2025-01-06 04:32:20 字数 591 浏览 3 评论 0原文

FuelPHP 中的 ORM 有一个如下所示的更新示例:

$entry = Model_Article::find(4);
$entry->title = 'My first edit';
$entry->author = 'Total n00b';
$entry->save();

我想知道我是否有能力进行如下更新:

$values = array(
     'this' => $that
);

Model_Article::find(4)->save($values);

插入功能允许传递值数组:

$props = array('property' => 'something');

$new = Model_Example::forge($props)->save();

但我没有看到执行以下操作的示例 :具有更新能力也是如此。

编辑:看来 Model_Example::find(4)->values($array)->save(); 是我正在寻找的。

The ORM in FuelPHP has an update example that looks like this:

$entry = Model_Article::find(4);
$entry->title = 'My first edit';
$entry->author = 'Total n00b';
$entry->save();

I'm wondering if there is an ability for me to update w/ something like this:

$values = array(
     'this' => $that
);

Model_Article::find(4)->save($values);

The insert ability allows for passing arrays of values:

$props = array('property' => 'something');

$new = Model_Example::forge($props)->save();

But I see no example of doing the same thing w/ the update ability.

EDIT: It appears Model_Example::find(4)->values($array)->save(); is what I'm looking for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三岁铭 2025-01-13 04:32:20

看来 Model_Example::find(4)->values($array)->save(); 就是我正在寻找的。

It appears Model_Example::find(4)->values($array)->save(); is what I'm looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文