如何在 Kohana 3.0 中更新记录

发布于 2024-12-14 09:36:10 字数 468 浏览 6 评论 0原文

我想更新表中的一条记录。我正在使用 Kohana 3.0 和 ORM。我的代码如下 -

$photo_sel =  $this->where('id','=',$this_photo_id)
                   ->where('user_id','=',$user_id)
                   ->where('is_logo','=','0')->find();

        if ($photo_sel->loaded()) {     
             $this->photo_file_name = $photo;                
              parent::save();
        }

但每次更新第一条记录时。相反,我想使用 $this_photo_id 选择并更新记录。

我怎样才能做到这一点?

I want to update a record in a table. I'm using Kohana 3.0 and ORM. My code is as follows -

$photo_sel =  $this->where('id','=',$this_photo_id)
                   ->where('user_id','=',$user_id)
                   ->where('is_logo','=','0')->find();

        if ($photo_sel->loaded()) {     
             $this->photo_file_name = $photo;                
              parent::save();
        }

But every time the first record is updated. Instead I want to select and update the record with $this_photo_id.

How can I achieve this ?

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

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

发布评论

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

评论(1

吾家有女初长成 2024-12-21 09:36:10

如果要更新选定的记录,只修改并保存该记录:

$photo_sel =  $this->where('id','=',$this_photo_id)
                   ->where('user_id','=',$user_id)
                   ->where('is_logo','=','0')->find();

if ($photo_sel->loaded()) {     
     $photo_sel->photo_file_name = $photo;                
     $photo_sel->save();
}

If you want to update the selected record, modify and save this record only:

$photo_sel =  $this->where('id','=',$this_photo_id)
                   ->where('user_id','=',$user_id)
                   ->where('is_logo','=','0')->find();

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