Agora_Driver_SplitSql::_getThreads PHP Метод

_getThreads() защищенный Метод

Returns a list of threads.
protected _getThreads ( integer $thread_root, boolean $all_levels = false, string $sort_by = 'message_modifystamp', integer $sort_dir, boolean $message_view = false, string $from, string $count )
$thread_root integer Message at which to start the thread. If null get all forum threads
$all_levels boolean Show all child levels or just one level.
$sort_by string The column by which to sort.
$sort_dir integer The direction by which to sort: 0 - ascending 1 - descending
$message_view boolean
$from string The thread to start listing at.
$count string The number of threads to return.
    protected function _getThreads($thread_root = 0, $all_levels = false, $sort_by = 'message_modifystamp', $sort_dir = 0, $message_view = false, $from = 0, $count = 0)
    {
        /* Cache */
        $key = $this->_scope . ':' . $this->_forum_id . ':' . $thread_root . ':' . intval($all_levels) . ':' . $sort_by . ':' . $sort_dir . ':' . intval($message_view) . ':' . intval($from) . ':' . intval($count);
        $messages = $this->_getCache($key, $thread_root);
        if ($messages) {
            return unserialize($messages);
        }
        $bind = $this->_buildThreadsQuery(null, $thread_root, $all_levels, $sort_by, $sort_dir, $message_view, $from, $count);
        /* Slice direcly in DB. */
        if ($sort_by != 'message_thread' && $count) {
            $bind[0] = $this->_db->addLimitOffset($bind[0], array('limit' => $count, 'offset' => $from));
        }
        try {
            $messages = $this->_db->select($bind[0], $bind[1]);
        } catch (Horde_Db_Exception $e) {
            throw new Agora_Exception($e->getMessage());
        }
        $messages = $this->_formatThreads($messages, $sort_by, $message_view, $thread_root);
        $this->_setCache($key, serialize($messages), $thread_root);
        return $messages;
    }