如何在数据库中插入对象
如何在 kohana 3 的数据库中插入对象?
我的代码是:
$application = DB::query(Database::SELECT,"SELECT * FROM application_settings WHERE 'id' = 1")->as_object()->execute();
$application -> google_analytical = $_POST['google_txt'];
$application = DB::insert('application_settings',$application)->execute();
$this->template->inner->status_msg = "Record has been saved successfully";
我想将名为application的对象插入数据库。
How can I insert an object in database in kohana 3?
My code is:
$application = DB::query(Database::SELECT,"SELECT * FROM application_settings WHERE 'id' = 1")->as_object()->execute();
$application -> google_analytical = $_POST['google_txt'];
$application = DB::insert('application_settings',$application)->execute();
$this->template->inner->status_msg = "Record has been saved successfully";
I want to insert the object named application into the database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DB::insert()
语法是:顺便说一下,为什么要 INSERT 新记录而不是 更新现有的吗?
UPD。您正在寻找单行,因此:
DB::insert()
syntax is:By the way, why do you want to INSERT new record instead of UPDATEing an existing one?
UPD. You are looking for a single row, so: