[eluser]InsiteFX[/eluser]
Your function query is over writing your model query.
You need to save the model query next query for it to work.
I had this same problem when I wrote my delete sessions method, I had to save the query first.
Here is the code for my delete old sessions it is in a MY_Sessions
Code:
// --------------------------------------------------------------------
/**
* sess_cleanup() - called from sess_destroy()
*
* Cleanup expired sessions in the database ci_sessions table.
* Checks on expired sessions and deletes them from the table.
*
* @access private
* @return void
*/
private function _sess_cleanup()
{
if ($this->sess_use_database != TRUE)
{
return;
}
$CI = get_instance();
$CI->load->database();
$query = $CI->db->get($this->sess_table_name);
$check = $query; // so queries are not over-written!
if ($check->num_rows() > 0)
{
foreach ($check->result() as $row)
{
// has this session expired?
$CI->db->where('session_id', $row->session_id);
$CI->db->get($this->sess_table_name);
$last_activity = $row->last_activity;
$expire = $this->now - $this->sess_expiration;
// seesion has expired so delete it!
if ($last_activity < $expire)
{
$CI->db->where('session_id', $row->session_id);
$CI->db->delete($this->sess_table_name);
}
}
}
}