简体   繁体   中英

Typo3 Extbase query result sorting by title after offset sorted by date

i have a extbase query result set with an offset of let's say 15 objects sorted by date (crdate DESC), so the 15 latest elements are skipped. The sorting of my actual result set should now be sorted by a different field, eg the 'title' field.

I have this case because I display the latest 15 elements in a different plugin on the site before. At the bottom of the website I want to display all but the first 15 elements in an archive list that has a filter function to filter by date ASC or title DESC.

I guess this is not possible with the default Extbase API, and I have to build a mySQL query myself. How would such a query look like ?

thanks!!!

I found out that it's possible to do that in mySQL with 'encapsulated' queries such as the following

SELECT * 
FROM  (
    SELECT * 
    FROM `tx_dentalarticle_domain_model_article` 
    WHERE  `type` = 0
    ORDER BY `tx_dentalarticle_domain_model_article`.`date` DESC 
    LIMIT 15 , 9999
) AS articles
ORDER BY `title` DESC 

to use it in extbase you have to use a raw statement such as:

$query = $this->createQuery();
$query->getQuerySettings()->setReturnRawQueryResult(TRUE);
$query->statement($sql);
return $query->execute();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM