本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectManager::createNativeQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::createNativeQuery方法的具体用法?PHP ObjectManager::createNativeQuery怎么用?PHP ObjectManager::createNativeQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::createNativeQuery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: countByAssetCollection
/**
* 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();
}
示例2: displayStatsAction
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);
}
示例3: countByTag
/**
* 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();
}