/** * @param string $key Cache key * @param string $sort_field Sorting column * @param string $sort_order Sorting order * @return array Messages index * @access private */ private function get_message_cache_index($key, $sort_field = 'idx', $sort_order = 'ASC') { if (!$this->caching_enabled || empty($key)) { return NULL; } // use idx sort as default if (!$sort_field || !in_array($sort_field, $this->db_header_fields)) { $sort_field = 'idx'; } if (array_key_exists('index', $this->icache) && $this->icache['index']['key'] == $key && $this->icache['index']['sort_field'] == $sort_field) { if ($this->icache['index']['sort_order'] == $sort_order) { return $this->icache['index']['result']; } else { return array_reverse($this->icache['index']['result'], true); } } $this->icache['index'] = array('result' => array(), 'key' => $key, 'sort_field' => $sort_field, 'sort_order' => $sort_order); $sql_result = $this->db->query("SELECT idx, uid" . " FROM " . get_table_name('messages') . " WHERE user_id=?" . " AND cache_key=?" . " ORDER BY " . $this->db->quote_identifier($sort_field) . " " . $sort_order, $_SESSION['user_id'], $key); while ($sql_arr = $this->db->fetch_assoc($sql_result)) { $this->icache['index']['result'][$sql_arr['idx']] = intval($sql_arr['uid']); } return $this->icache['index']['result']; }