Get all records in db typo3 table page 4.6.1

I want all the entries for a page, but I need it to work for the specific language and workspace the user is in.

In traditional typo3, I used something like:

        $query = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
            '*',         // SELECT ...
            'tx_faqs_domain_model_faqsections',     // FROM ...
            'pid=' . (int) $pid . ' and deleted=0 and hidden=0 and sys_language_uid=' . $lang . ' AND t3ver_wsid = ' . (int) $workspace,    // WHERE...
            '',            // GROUP BY...
            'sorting',    // ORDER BY...
            ''            // LIMIT ...
    foreach ($query as $key => $value) {
        $data[$key] = utf8_encode($value); 


However, the following does not work with workspaces and does not seem like the new flow3 environment.

I watched:

    $query = $this->createQuery();
    return $query->execute();


inside my Tx_Faqs_Domain_Repository_FaqSectionsRepository class, but this returns an empty array.

An example of getting all records for a specific page in a specific workspace for a specific language from a db table would be ideal.


source to share

1 answer

Add a method to your repository that does the filtering for you:

public function findAllFromPage(){
    $query = $this->createQuery();

    $pid = intval($GLOBALS['TSFE']->id);
    $query->matching($query->equals('pid',$pid ));
    return $query->execute();


The important bit is that you set respectStoragePage

to false, otherwise it just looks for entries in the configured repository pid (this is also the reason the magic type function findByPid($GLOBALS['TSFE']->id);

available in the repository class anyway won't work)



All Articles