本文整理汇总了PHP中Doctrine\ORM\QueryBuilder::linkLeft方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::linkLeft方法的具体用法?PHP QueryBuilder::linkLeft怎么用?PHP QueryBuilder::linkLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::linkLeft方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareCndInventoryIn
/**
* Add inventory condition to search in-stock products
*
* @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
*
* @return void
*/
protected function prepareCndInventoryIn(\Doctrine\ORM\QueryBuilder $queryBuilder)
{
$queryBuilder->linkLeft('p.variants', 'pv');
$orCnd = new \Doctrine\ORM\Query\Expr\Orx();
$orCnd->add('i.enabled = :disabled');
$orCnd->add('i.amount > :zero');
$orCnd->add('pv.amount > :zero');
$queryBuilder->andWhere($orCnd)->setParameter('disabled', false)->setParameter('zero', 0);
}
示例2: prepareCndOrderBy
/**
* Prepare certain search condition
*
* @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
* @param array $value Condition data
* @param boolean $countOnly "Count only" flag. Do not need to add "order by" clauses if only count is needed.
*
* @return void
*/
protected function prepareCndOrderBy(\Doctrine\ORM\QueryBuilder $queryBuilder, array $value, $countOnly)
{
list($sort, $order) = $this->getSortOrderValue($value);
if ('r.bought' == $sort) {
if (!$countOnly) {
$queryBuilder->linkLeft('p.order_items')->linkLeft('order_items.order')->linkLeft('order.paymentStatus')->andWhere('(paymentStatus.id IS NULL OR ' . $queryBuilder->expr()->in('paymentStatus.code', \XLite\Model\Order\Status\Payment::getPaidStatuses()) . ')')->addSelect('sum(order_items.amount) as product_amount')->addOrderBy('product_amount', $order);
}
$value = array('translations.name', $order);
}
parent::prepareCndOrderBy($queryBuilder, $value, $countOnly);
}
示例3: prepareCndOrderBy
/**
* Prepare certain search condition
*
* @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
* @param array $value Condition data
* @param boolean $countOnly "Count only" flag. Do not need to add "order by" clauses if only count is needed.
*
* @return void
*/
protected function prepareCndOrderBy(\Doctrine\ORM\QueryBuilder $queryBuilder, array $value, $countOnly)
{
if (!$countOnly) {
list($sort, $order) = $this->getSortOrderValue($value);
if ('r.rating' == $sort) {
$queryBuilder->linkLeft('p.reviews', 'r');
$queryBuilder->addSelect('SUM(r.rating) as rsm');
$sort = 'rsm';
$queryBuilder->addOrderBy($sort, $order);
} else {
parent::prepareCndOrderBy($queryBuilder, $value, $countOnly);
}
}
}
示例4: prepareOrderByAddressField
/**
* Prepare fields for fullname value (for 'order by')
*
* @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder object
* @param string $fieldName Field name
*
* @return void
*/
protected function prepareOrderByAddressField(\Doctrine\ORM\QueryBuilder $queryBuilder, $fieldName)
{
$addressFieldName = 'address_field_value_' . $fieldName;
$addressField = \XLite\Core\Database::getRepo('XLite\\Model\\AddressField')->findOneBy(array('serviceName' => $fieldName));
$queryBuilder->linkLeft('addresses.addressFields', $addressFieldName, \Doctrine\ORM\Query\Expr\Join::WITH, $addressFieldName . '.addressField = :' . $fieldName)->setParameter($fieldName, $addressField);
}
示例5: addMembershipCondition
/**
* Adds additional condition to the query for checking if product has available membership
*
* @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder object
* @param string $alias Entity alias OPTIONAL
*
* @return void
*/
protected function addMembershipCondition(\Doctrine\ORM\QueryBuilder $queryBuilder, $alias = null)
{
if (!\XLite::isAdminZone()) {
$alias = $alias ?: $queryBuilder->getRootAlias();
$membership = \XLite\Core\Auth::getInstance()->getMembershipId();
$queryBuilder->linkLeft($alias . '.memberships', 'membership');
if ($membership) {
$queryBuilder->andWhere('membership.membership_id = :membershipId OR membership.membership_id IS NULL')->setParameter('membershipId', \XLite\Core\Auth::getInstance()->getMembershipId());
} else {
$queryBuilder->andWhere('membership.membership_id IS NULL');
}
}
}
示例6: prepareCndZone
/**
* Prepare certain search condition
*
* @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
* @param array|string $value Condition data
* @param boolean $countOnly "Count only" flag. Do not need to add "order by" clauses
* if only count is needed.
*
* @return void
*/
protected function prepareCndZone(\Doctrine\ORM\QueryBuilder $queryBuilder, $value, $countOnly)
{
$values = array_values($value);
if (isset($values[0]) && $values[0] == self::SEARCH_ZONE_CUSTOMER && \XLite\Core\Config::getInstance()->XC->Reviews->disablePendingReviews == true) {
$statusCondition = 'r.status = ' . \XLite\Module\XC\Reviews\Model\Review::STATUS_APPROVED;
if ($values[1] instanceof \XLite\Model\Profile) {
$queryBuilder->linkLeft('r.profile', 'u');
$queryBuilder->andWhere($statusCondition . ' OR u.profile_id = :profileId')->setParameter('profileId', $values[1]->getProfileId());
} else {
$reviewIds = \XLite\Core\Session::getInstance()->reviewIds;
if (is_array($reviewIds) && !empty($reviewIds)) {
$queryBuilder->andWhere($statusCondition . ' OR r.id IN (' . implode(', ', $reviewIds) . ')');
} else {
$queryBuilder->andWhere($statusCondition);
}
}
}
}
示例7: prepareCndUserType
/**
* prepareCndUserType
*
* @param \Doctrine\ORM\QueryBuilder $queryBuilder QueryBuilder instance
* @param mixed $value Searchable value
*
* @return void
*/
protected function prepareCndUserType(\Doctrine\ORM\QueryBuilder $queryBuilder, $value)
{
$roles = array();
if (!is_array($value)) {
$value = array($value);
}
$condition = $queryBuilder->expr()->orX();
foreach ($value as $selectedType) {
if (is_numeric($selectedType)) {
$roles[] = $selectedType;
} elseif ('C' == $selectedType) {
$condition->add($queryBuilder->expr()->andX($queryBuilder->getRegisteredCondition(), $queryBuilder->getCustomerCondition()));
$queryBuilder->setParameter('anonymous', true)->setParameter('adminAccessLevel', \XLite\Core\Auth::getInstance()->getAdminAccessLevel());
} elseif ('N' == $selectedType) {
$condition->add($queryBuilder->expr()->andX($queryBuilder->getAnonymousCondition(), $queryBuilder->getCustomerCondition()));
$queryBuilder->setParameter('anonymous', true)->setParameter('adminAccessLevel', \XLite\Core\Auth::getInstance()->getAdminAccessLevel());
}
}
if ($roles) {
$condition->add($queryBuilder->expr()->andX($queryBuilder->getRegisteredCondition(), $queryBuilder->getAdminCondition(), $queryBuilder->getRolesCondition($roles)));
$queryBuilder->linkLeft('p.roles')->setParameter('anonymous', true)->setParameter('adminAccessLevel', \XLite\Core\Auth::getInstance()->getAdminAccessLevel());
}
if ($condition->count()) {
$queryBuilder->andWhere($condition);
}
}