Bob0101
Bob0101

Reputation: 187

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', '=', $_POST['name'])
    ->find();

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

Upvotes: 1

Views: 1155

Answers (2)

slacker
slacker

Reputation: 391

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);

Upvotes: 1

Kemo
Kemo

Reputation: 7042

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.

Upvotes: 1

Related Questions