D
Deleted member 10469
Guest
Hello, how make a query for get à 5 last thread please ?
I have that:
But only 'limit' worked.
xenforo function used (in Model/Thread.php) :
I have that:
PHP:
<?php
$sujets = XenForo_Model::create('XenForo_Model_Thread');
$whereConditions = array('id' => '1,2');
$fetchOptions = array('limit' => 3, 'orderBy' => 'title desc');
$threads = $sujets->getThreads($whereConditions, $fetchOptions);
var_dump($threads);
?>
But only 'limit' worked.
xenforo function used (in Model/Thread.php) :
PHP:
<?php
/**
* Gets threads that match the given conditions.
*
* @param array $conditions Conditions to apply to the fetching
* @param array $fetchOptions Collection of options that relate to fetching
*
* @return array Format: [thread id] => info
*/
public function getThreads(array $conditions, array $fetchOptions = array())
{
$whereConditions = $this->prepareThreadConditions($conditions, $fetchOptions);
$sqlClauses = $this->prepareThreadFetchOptions($fetchOptions);
$limitOptions = $this->prepareLimitFetchOptions($fetchOptions);
$forceIndex = (!empty($fetchOptions['forceThreadIndex']) ? 'FORCE INDEX (' . $fetchOptions['forceThreadIndex'] . ')' : '');
return $this->fetchAllKeyed($this->limitQueryResults(
'
SELECT thread.*
' . $sqlClauses['selectFields'] . '
FROM xf_thread AS thread ' . $forceIndex . '
' . $sqlClauses['joinTables'] . '
WHERE ' . $whereConditions . '
' . $sqlClauses['orderClause'] . '
', $limitOptions['limit'], $limitOptions['offset']
), 'thread_id');
}