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 ssh登录页面的问题
  • ¥60 渗透一个指定银行app,拿到客户信息,需要什么级别
  • ¥50 关于在matlab上对曲柄摇杆机构上一点的运动学仿真
  • ¥15 jetson nano
  • ¥15 :app:debugCompileClasspath'.
  • ¥15 windows c++内嵌qt出现数据转换问题。
  • ¥20 公众号如何实现点击超链接后自动发送文字
  • ¥15 用php隐藏类名和增加类名
  • ¥15 算法设计与分析课程的提问
  • ¥15 用MATLAB汇总拟合图