Kohana3 ORM保存问题
任何人都可以帮助我使用 Kohana ORM。我可以取出名称和值。我可以给它们新的值,并尝试将它们保存回基础,但在 phpmyadmin 中我可以看到这些选项属性的旧值。这段代码有什么问题(它可以工作并回显正确的值,但我在数据库中看不到它):
$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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是您要找的吗?
Is this what you are looking for?
尝试检查数据是否通过“$option->loaded()”加载,或者在“find()”后回显$option(它会返回它的主键)。
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.