开发者

Kohana3 ORM save problem

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜