【发布时间】:2012-11-21 01:18:02
【问题描述】:
我使用活动记录将值插入数据库。
所有其他类型的查询我都使用自定义查询,因为它更容易,但活动记录插入非常好。
所以我有这个代码:
$comment = array (
'point_id' => $object->id,
'title' => $object->title,
'comment' => $object->comment,
'author_name' => $object->author_name,
'is_temp' => 0,
'parent_id' => $object->parent_id
);
return $this->db->insert('comments', $comment);
现在我希望能够将 is_temp 设置为子查询结果,即:
(SELECT allow_user_comments from subjects where id='somevalue')
如何做到这一点?
我希望避免使用第三方库。
【问题讨论】:
-
只是一个注释。 Codeigniter 没有活动记录。它只有查询生成器。
-
@itachi 不正确。见本页第一段 - ellislab.com/codeigniter/user-guide/database/active_record.html
-
相关,可能对你有用-stackoverflow.com/questions/6047149/…
-
@Catfish 这是来自开发人员的误导性信息。 Codeigniter AR 没有 Proper AR 的基础,只是查询构建器(打开它你会看到)。
-
你能贴出你想要实现的整个查询的sql吗?
标签: php sql codeigniter codeigniter-2