本文整理汇总了PHP中EntityManager::createQueryBuilder方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::createQueryBuilder方法的具体用法?PHP EntityManager::createQueryBuilder怎么用?PHP EntityManager::createQueryBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::createQueryBuilder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialisation
*
* @access private
*/
private function init()
{
// check the content for installed and used modules
$arrCmActiveModules = array();
$arrCmInstalledModules = array();
$qb = $this->em->createQueryBuilder();
$qb->add('select', 'p')->add('from', 'Cx\\Core\\ContentManager\\Model\\Entity\\Page p')->add('where', $qb->expr()->neq('p.module', $qb->expr()->literal('')));
$pages = $qb->getQuery()->getResult();
foreach ($pages as $page) {
$arrCmInstalledModules[] = $page->getModule();
if ($page->isActive()) {
$arrCmActiveModules[] = $page->getModule();
}
}
$arrCmInstalledModules = array_unique($arrCmInstalledModules);
$arrCmActiveModules = array_unique($arrCmActiveModules);
// add static modules
$arrCmInstalledModules[] = 'Block';
$arrCmInstalledModules[] = 'Crm';
$arrCmInstalledModules[] = 'Order';
$arrCmInstalledModules[] = 'Pim';
$arrCmInstalledModules[] = 'Support';
$arrCmActiveModules[] = 'Block';
$arrCmInstalledModules[] = 'upload';
$arrCmActiveModules[] = 'upload';
$objResult = $this->db->Execute('SELECT `name`, `is_core`, `is_required` FROM `' . DBPREFIX . 'modules`');
if ($objResult !== false) {
while (!$objResult->EOF) {
$moduleName = $objResult->fields['name'];
if ($moduleName == 'News') {
$this->arrModules[] = $moduleName;
//$this->arrCoreModules[] = $moduleName;
if (in_array($moduleName, $arrCmInstalledModules)) {
$this->arrInstalledModules[] = $moduleName;
if (in_array($moduleName, $arrCmInstalledModules)) {
$this->arrActiveModules[] = $moduleName;
}
}
$objResult->MoveNext();
continue;
}
if (!empty($moduleName)) {
$isCore = $objResult->fields['is_core'];
if ($isCore == 1) {
$this->arrCoreModules[] = $moduleName;
} else {
$this->arrModules[] = $moduleName;
}
if (in_array($moduleName, $arrCmInstalledModules) && ($isCore || !$isCore && is_dir($this->cl->getFilePath(ASCMS_MODULE_PATH . '/' . $moduleName)))) {
$this->arrInstalledModules[] = $moduleName;
}
if (in_array($moduleName, $arrCmActiveModules) && ($isCore || !$isCore && is_dir($this->cl->getFilePath(ASCMS_MODULE_PATH . '/' . $moduleName)))) {
$this->arrActiveModules[] = $moduleName;
}
}
$objResult->MoveNext();
}
}
}
示例2: markIsReadByParticipant
/**
* Marks the message as read or unread by this participant
*
* @param MessageInterface $message
* @param ParticipantInterface $participant
* @param boolean $isRead
*/
protected function markIsReadByParticipant(MessageInterface $message, ParticipantInterface $participant, $isRead)
{
$meta = $message->getMetadataForParticipant($participant);
if (!$meta || $meta->getIsRead() == $isRead) {
return;
}
$this->em->createQueryBuilder()->update($this->metaClass, 'm')->set('m.isRead', '?1')->setParameter('1', (bool) $isRead, \PDO::PARAM_BOOL)->where('m.id = :id')->setParameter('id', $meta->getId())->getQuery()->execute();
}
示例3: createQueryBuilder
/**
* Create a new QueryBuilder instance that is prepopulated for this entity name
*
* @param string $alias
* @return QueryBuilder $qb
*/
public function createQueryBuilder($alias)
{
return $this->_em->createQueryBuilder()->select($alias)->from($this->_entityName, $alias);
}
示例4: fetch
/**
* Uses the given Entity Manager to retrieve all links for the placeholders
* @param EntityManager $em
*/
public function fetch($em)
{
if ($this->placeholders === null) {
throw new LinkGeneratorException('Seems like scan() was never called before calling fetch().');
}
$qb = $em->createQueryBuilder();
$qb->add('select', new Doctrine\ORM\Query\Expr\Select(array('p')));
$qb->add('from', new Doctrine\ORM\Query\Expr\From('Cx\\Core\\ContentManager\\Model\\Entity\\Page', 'p'));
//build a big or with all the node ids and pages
$arrExprs = null;
$fetchedPages = array();
$pIdx = 0;
foreach ($this->placeholders as $placeholder => $data) {
if ($data['type'] == 'id') {
# page is referenced by NODE-ID (i.e.: [[NODE_1]])
if (isset($fetchedPages[$data['nodeid']][$data['lang']])) {
continue;
}
$arrExprs[] = $qb->expr()->andx($qb->expr()->eq('p.node', $data['nodeid']), $qb->expr()->eq('p.lang', $data['lang']));
$fetchedPages[$data['nodeid']][$data['lang']] = true;
} else {
# page is referenced by module (i.e.: [[NODE_SHOP_CART]])
if (isset($fetchedPages[$data['module']][$data['cmd']][$data['lang']])) {
continue;
}
$arrExprs[] = $qb->expr()->andx($qb->expr()->eq('p.type', ':type'), $qb->expr()->eq('p.module', ':module_' . $pIdx), $qb->expr()->eq('p.cmd', ':cmd_' . $pIdx), $qb->expr()->eq('p.lang', $data['lang']));
$qb->setParameter('module_' . $pIdx, $data['module']);
$qb->setParameter('cmd_' . $pIdx, empty($data['cmd']) ? null : $data['cmd']);
$qb->setParameter('type', \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION);
$fetchedPages[$data['module']][$data['cmd']][$data['lang']] = true;
$pIdx++;
}
}
//fetch the nodes if there are any in the query
if ($arrExprs) {
foreach ($arrExprs as $expr) {
$qb->orWhere($expr);
}
$pages = $qb->getQuery()->getResult();
foreach ($pages as $page) {
// build placeholder's value -> URL
$url = \Cx\Core\Routing\Url::fromPage($page);
$placeholderByApp = '';
$placeholderById = \Cx\Core\ContentManager\Model\Entity\Page::PLACEHOLDER_PREFIX . $page->getNode()->getId();
$this->placeholders[$placeholderById . '_' . $page->getLang()] = $url;
if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) {
$module = $page->getModule();
$cmd = $page->getCmd();
$placeholderByApp = \Cx\Core\ContentManager\Model\Entity\Page::PLACEHOLDER_PREFIX;
$placeholderByApp .= strtoupper($module . (empty($cmd) ? '' : '_' . $cmd));
$this->placeholders[$placeholderByApp . '_' . $page->getLang()] = $url;
}
if ($page->getLang() == FRONTEND_LANG_ID) {
$this->placeholders[$placeholderById] = $url;
if (!empty($placeholderByApp)) {
$this->placeholders[$placeholderByApp] = $url;
}
}
}
}
// there might be some placeholders we were unable to resolve.
// try to resolve them by using the fallback-language-reverse-lookup
// methode provided by \Cx\Core\Routing\Url::fromModuleAndCmd().
foreach ($this->placeholders as $placeholder => $data) {
if (!$data instanceof \Cx\Core\Routing\Url) {
if (!empty($data['module'])) {
try {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['cmd'], $data['lang'], array(), '', false);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
} catch (\Cx\Core\Routing\UrlException $e) {
if ($data['lang'] && $data['cmd']) {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['cmd'] . '_' . $data['lang'], FRONTEND_LANG_ID);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
} else {
if ($data['lang'] && empty($data['cmd'])) {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['lang'], FRONTEND_LANG_ID);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
} else {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd('Error', '', $data['lang']);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
}
}
}
} else {
//.........这里部分代码省略.........
示例5: getPaginatedResults
/**
* Get paginated results.
*
* @param int $page Current page
* @param int $limit Items per page limit
* @param array $sortby Sorting options
*
* @return \Knp\Component\Pager\Pagination\PaginationInterface Returns a filtered paginator
*/
public function getPaginatedResults($page = 1, $limit = 15, array $sortby = array())
{
$qb = $this->objectManager->createQueryBuilder(self::ENTITY_ALIAS)->select(self::ENTITY_ALIAS)->from(self::ENTITY_CLASS, self::ENTITY_ALIAS);
return $this->getPaginator()->paginate($qb, $page, $limit, $sortby);
}
示例6: updateArticleWebcode
/**
* Updates article webcode
*
* @param EntityManager $em Entity Manager
* @param string $webcode Article webcode
* @param int $articleNumber Article number
*
* @return void
*/
private function updateArticleWebcode($em, $webcode, $articleNumber)
{
$queryBuilder = $em->createQueryBuilder();
$query = $queryBuilder->update('Newscoop\\Entity\\Article', 'a')->set('a.webcode', $queryBuilder->expr()->literal($webcode))->where('a.number = :number')->setParameter('number', $articleNumber)->getQuery();
$query->execute();
}