Use query builder
This commit is contained in:
@@ -27,24 +27,36 @@ namespace EP\EpProducts\Domain\Repository;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpProducts\Domain\Model\Faq;
|
||||
use TYPO3\CMS\Core\Database\Connection;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
|
||||
|
||||
class FaqRepository extends AbstractRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $uids
|
||||
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
|
||||
* @return array
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
public function findByUids($uids)
|
||||
{
|
||||
$query = $this->createQuery();
|
||||
$query->statement('
|
||||
SELECT * FROM tx_epproducts_domain_model_faq
|
||||
WHERE uid IN (' . $uids . ')' .
|
||||
' ' .$GLOBALS['TSFE']->sys_page->enableFields('tx_epproducts_domain_model_faq') .
|
||||
' ORDER BY FIELD(uid, ' . $uids . ')
|
||||
');
|
||||
/** @var DataMapper $dataMapper */
|
||||
$dataMapper = GeneralUtility::makeInstance(DataMapper::class);
|
||||
$qb = $this->getDbConnection()->createQueryBuilder();
|
||||
|
||||
return $query->execute();
|
||||
$rows = $qb
|
||||
->select('*')
|
||||
->from('tx_epproducts_domain_model_faq')
|
||||
->where('uid IN (:uids)')
|
||||
->add('orderBy', 'FIELD(uid, ' . $uids . ')')
|
||||
->setParameter('uids', GeneralUtility::trimExplode(',', $uids), Connection::PARAM_INT_ARRAY)
|
||||
->execute()
|
||||
->fetchAll()
|
||||
;
|
||||
|
||||
return $dataMapper->map(Faq::class, $rows);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user