/**
  * Count assets by asset collection
  *
  * @param AssetCollection $assetCollection
  * @return integer
  */
 public function countByAssetCollection(AssetCollection $assetCollection)
 {
     $rsm = new ResultSetMapping();
     $rsm->addScalarResult('c', 'c');
     $queryString = "SELECT count(a.persistence_object_identifier) c FROM typo3_media_domain_model_asset a LEFT JOIN typo3_media_domain_model_assetcollection_assets_join collectionmm ON a.persistence_object_identifier = collectionmm.media_asset WHERE collectionmm.media_assetcollection = ? AND a.dtype != 'typo3_media_imagevariant'";
     $query = $this->entityManager->createNativeQuery($queryString, $rsm);
     $query->setParameter(1, $assetCollection);
     return $query->getSingleScalarResult();
 }
 public function displayStatsAction()
 {
     $queryString = "SELECT worldviewIdentifier as worldview, count(*) AS count FROM sfi_encult_domain_model_vote GROUP BY worldviewIdentifier;";
     $rsm = new \Doctrine\ORM\Query\ResultSetMapping();
     $rsm->addScalarResult('worldview', 'worldview');
     $rsm->addScalarResult('count', 'count');
     $query = $this->entityManager->createNativeQuery($queryString, $rsm);
     $voteResults = array();
     foreach ($query->getResult() as $row) {
         if ($row['worldview']) {
             $worldviewNode = $this->liveContext->getNodeByIdentifier($row['worldview']);
             $voteResults[$worldviewNode->getProperty('title')] = $row['count'];
         }
     }
     $this->view->assign('voteResults', $voteResults);
 }
Exemple #3
0
 /**
  * Counts Assets with the given Tag assigned
  *
  * @param \TYPO3\Media\Domain\Model\Tag $tag
  * @param AssetCollection $assetCollection
  * @return integer
  */
 public function countByTag(\TYPO3\Media\Domain\Model\Tag $tag, AssetCollection $assetCollection = NULL)
 {
     $rsm = new \Doctrine\ORM\Query\ResultSetMapping();
     $rsm->addScalarResult('c', 'c');
     if ($assetCollection === NULL) {
         $queryString = 'SELECT count(a.persistence_object_identifier) c FROM typo3_media_domain_model_asset a LEFT JOIN typo3_media_domain_model_asset_tags_join mm ON a.persistence_object_identifier = mm.media_asset WHERE mm.media_tag = ?';
     } else {
         $queryString = 'SELECT count(a.persistence_object_identifier) c FROM typo3_media_domain_model_asset a LEFT JOIN typo3_media_domain_model_asset_tags_join tagmm ON a.persistence_object_identifier = tagmm.media_asset LEFT JOIN typo3_media_domain_model_assetcollection_assets_join collectionmm ON a.persistence_object_identifier = collectionmm.media_asset WHERE tagmm.media_tag = ? AND collectionmm.media_assetcollection = ?';
     }
     $query = $this->entityManager->createNativeQuery($queryString, $rsm);
     $query->setParameter(1, $tag);
     if ($assetCollection !== NULL) {
         $query->setParameter(2, $assetCollection);
     }
     return $query->getSingleScalarResult();
 }