English 中文(简体)
• 如何更新科加纳的记录3.0
原标题:How to update a record in Kohana 3.0

我想在一份表格中更新一个记录。 I m使用Koha 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();
        }

但第一次记录每次更新。 相反,我要用这番钱来挑选和更新记录。

我如何能够做到这一点?

最佳回答

如果你想要更新选定的记录,只修改和拯救这一记录:

$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();
}
问题回答

暂无回答




相关问题
Kohana ORM relationships question

I have tables: users {id, name} projects {id, name} roles {id, name} projects_users {id, user_id, project_id, role_id} I have models: project { has many users through projects_users } user { has ...

How to delete all user roles in Kohana 3

I m using ORM Auth module and it s difficult to figure out how to do it. I ve tried this case: $user = ORM::factory( user , $id); $user->roles->delete_all(); And got error ErrorException [ Fatal ...

Kohanav3 ORM: calling where->find_all twice

When I do something like the following: $site = ORM::factory( site )->where( name , = , Test Site )->find(); $users = $site->users; $deletedusers = $users->where( deleted , = , 1 )-&...

Kohana 3 simple relations

I m trying to write a very simple cms (for learning purposes) in kohana 3 web framework. I have my db schemas and i want to map it to ORM but i have problems with relations. Schemas:articles and ...

Kohana PHP - Multiple apps with shared model

I m using Kohana 3 to create a website that has two applications, an admin application and the actual site frontend. I have separated my folders to have the two applications separated, so the ...

Favourite Kohana Tips & Features? [closed]

Inspired from the other community wikis, I m interested in hearing about the lesser known Kohana tips, tricks and features. Please, include only one tip per answer. Add Kohana versions if necessary. ...

热门标签