Php 如何在调用同一模型两次时释放codeigniter结果

Php 如何在调用同一模型两次时释放codeigniter结果,php,codeigniter,Php,Codeigniter,我有一种情况,我在codeigniter中编写了一个基本模型,所有模型都是从它扩展而来的,基本模型有一个函数 public function load_all_by_keys($array, $limit = 0, $offset = 0) { if ($limit) { $query = $this->database->get_where($this::DB_TABLE, $array, $limit, $offset); } else { $query

我有一种情况,我在codeigniter中编写了一个基本模型,所有模型都是从它扩展而来的,基本模型有一个函数

public function load_all_by_keys($array, $limit = 0, $offset = 0) {
  if ($limit) {
    $query = $this->database->get_where($this::DB_TABLE, $array, $limit, $offset);
  } else {
    $query = $this->database->get_where($this::DB_TABLE, $array);
  }
  $ret_val = array();
  $class = get_class($this);
  foreach ($query->result() as $row) {
    $model = new $class;
    $model->populate($row);
    $ret_val[$row->{$this::DB_TABLE_PK}] = $model;
  }
  return $ret_val;
}
在这个函数中,我可以得到,比如说,属于教唆类别的学校

$abet = new School_Model();
// this query will get all schools with by column category whose value is Abet, thats fine
$abetSchools = $abet-?load_all_by_keys(array('category'=>'Abet'));
$primary = new School_Model();
// This second query fails with the error Fatal error: Call to a member function result() on a non-object
$primarySchools = $primary-?load_all_by_keys(array('category'=>'Primary'))
有人能帮忙吗

$this->db->flush_cache()

此函数用于删除活动记录缓存中的所有项目(参考)

您使用的是什么版本的codeIgniter?