codeIgniter活动记录与定期查询 [英] CodeIgniter Active Record vs. regular queries
问题描述
目前我使用codeIgniter定期查询,即:
Currently I use CodeIgniter with regular queries, i.e.:
$ SQL =
选择 *
FROM my_table的
WHERE ITEM_ID> 1
$ Q = $这个 - > DB->查询($ SQL);
$sql = "
SELECT *
FROM my_table
WHERE item_id > 1
";
$q = $this->db->query($sql);
我已经开始寻找到的ActiveRecord,而且它看起来不错,并有正在修建查询的优势,无论是哪个数据库驱动程序的使用 - 不过,我严格地使用每个在一般项目的单一数据库类型,所以这是没有真正为我的利益。
I have started looking into ActiveRecord, and it does look nice, and has the advantage of the query being built regardless of which database driver is used - however, I strictly use a single database type per project in general, so this is not really a benefit for me.
我发现,经常查询(正如我在我的例子),更容易阅读和维护在我看来,所以我现在想保持定期查询。
I found that regular queries (as I have in my example) are more readable and easier maintained in my opinion, so I am currently thinking of keeping with regular queries.
除了上面提到的原因,这应该让我选择,出于什么原因(S)?
Besides for the reasons mentioned above, which should I choose, and for what reason(s)?
感谢您
推荐答案
对我很好我preFER运行定期查询,CI的活动记录要消耗多少内存。因为它会加载所有结果在存储器中。如果你明白我的意思。至于复杂,最好要定期查询而坚持CI的活动记录的语法来。
well for me i prefer running regular queries, CI's active record consumes to much memory. because it will load all result in the memory. If you know what i mean. As for complexity it's better to go with regular query rather sticking to CI's active record sytax.
这篇关于codeIgniter活动记录与定期查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!