开发者

Kohana3 ORM save problem

开发者 https://www.devze.com 2022-12-29 18:04 出处:网络
Can anyone help me with Kohana ORM. I can take out name and value. I can give them new values and I try to save them back to base, but in phpmyadmin i can see still old values for these option attribu

Can anyone help me with Kohana ORM. I can take out name and value. I can give them new values and I try to save them back to base, but in phpmyadmin i can see still old values for these option attributes. What is wrong with this code (it works and echos right value but i can't see it in db):

$option = ORM::factory('draft')
->where('user_id', '=', $user_id)
->find()
    ->draft_options
    ->where('name', '='开发者_JS百科, $_POST['name'])
    ->find();

$option->name = $_POST['name'];
$option->value = $_POST['value'];
$option->save();
if ($option->saved()) echo Kohana::debug($option->value);


Is this what you are looking for?

$option = ORM::factory('draft')
    ->where('user_id', '=', $user_id)
    ->find();

$draft_option = $option->draft_options
    ->where('name', '=', $_POST['name'])
    ->find();

$draft_option->name = $_POST['name'];
$draft_option->value = $_POST['value'];
$draft_option->save();

if ($draft_option->saved()) echo Kohana::debug($draft_option->value);


Try checking does the data get loaded with "$option->loaded()", or echo the $option ( it'll return you it's primary key ) after you "find()" it please.

0

精彩评论

暂无评论...
验证码 换一张
取 消