dongzhi9192 2012-07-10 11:24
浏览 67
已采纳

CodeIgniter - 插入查询的Active Record Caching

I am currently attempting to create a fairly basic web app that has the potential to hold sensitive(ish) data for users and their organizations.

I had intended on storing all user entered record data in one db and all app data in another db.This data will be stored in a shared db with an user_id and org_id against all records in all tables to facilitate separation.

To minimize risk of code error and data compromise I have researched the ability to automatically append standard 'where' statements to my active record queries using Active Record Caching

$this->db->start_cache();
$this->db->where('user_id',$_SESSION['user_id']);
$this->db->where('org_id',$_SESSION['org_id']);
$this->db->stop_cache();

This is brilliant and will save a lot of headaches. However, According to the documentation http://codeigniter.com/user_guide/database/active_record.html#caching I should also be able to use this for updates (set method):

Note: The following statements can be cached: select, from, join, where, like, group_by, having, order_by, set.

Looking at the active_record class "DB_active_rec.php" there is code present to provide caching in several methods (select, where etc).

if ($this->ar_caching === TRUE)
{
...do caching stuff

From what I can tell this seems to be missing from the set method.

I'm not sure what answer I'm after but hopefully it will be that I'm just doing it wrong!

  • 写回答

1条回答 默认 最新

  • dpzbh1779 2012-07-10 11:57
    关注

    You can't cache update statements. It would not make much sense. In your update you use the $this->db->where()method, which essentially is a select. That part can be cached, and by doing that you save yourself a select statement.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog