Created
August 25, 2018 18:57
-
-
Save andrconstruction/70fb65bbff61b407fae6ab5a854e1a18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$offset = ( $page - 1 ) * $limit; | |
$qb = $this->_em->createQueryBuilder(); | |
$qb->select( | |
'c' | |
, 'cf' | |
, 'p' | |
, 'pf' | |
,'partial uc.{id,displayName,picture}' | |
,'partial ucp.{id,displayName,picture}' | |
) | |
->from( ProjectComment::class, 'c' ) | |
->leftJoin( 'c.files', 'cf' ) | |
->leftJoin( 'c.parent', 'p' ) | |
->leftJoin( 'p.files', 'pf' ) | |
->leftJoin('c.userCreate', 'uc') | |
->leftJoin('p.userCreate', 'ucp') | |
->orderBy( 'c.updated', 'desc' ) | |
->setMaxResults( $limit ) | |
->setFirstResult( $offset ); | |
if ( $taskId ) { | |
$qb->where( 'c.task = :taskId' ) | |
->setParameter( 'taskId', $taskId ); | |
} else { | |
$qb->where( 'c.project = :id' ) | |
->setParameter( 'id', $id ); | |
} | |
$query = $qb->getQuery(); | |
$a = $qb->getQuery()->getSQL(); | |
$query->setHint( Query::HINT_CUSTOM_OUTPUT_WALKER, AshPaginationWalker::class ); | |
$query->setHint( "mysqlWalker.sqlCalcFoundRows", true ); | |
$qb->getQuery()->getResult(); | |
$totalCount = $this->_em->getConnection()->query( 'SELECT FOUND_ROWS()' )->fetchColumn( 0 ); | |
// $qb = $this->_em->createQueryBuilder(); | |
// | |
// $qb->select( 'c', 'p','pf' ) | |
// ->from( ProjectComment::class, 'c' ) | |
// ->leftJoin( 'c.parent', 'p' ) | |
// ->leftJoin( 'p.files', 'pf' ); | |
// | |
// if ( $taskId ) { | |
// $qb->where( 'c.task = :taskId' ) | |
// ->setParameter( 'taskId', $taskId ); | |
// } else { | |
// $qb->where( 'c.project = :id' ) | |
// ->setParameter( 'id', $id ); | |
// } | |
// | |
// $qb->getQuery()->getResult(); | |
$rows = new ArrayCollection( $query->getResult() ); | |
$dd = $query->getArrayResult() ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment