当前位置: 首页>>代码示例>>PHP>>正文


PHP Database::buildInCondition方法代码示例

本文整理汇总了PHP中XLite\Core\Database::buildInCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::buildInCondition方法的具体用法?PHP Database::buildInCondition怎么用?PHP Database::buildInCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XLite\Core\Database的用法示例。


在下文中一共展示了Database::buildInCondition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareCndModuleIds

 /**
  * Prepare certain search condition
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param string|null                $value        Condition data
  *
  * @return void
  */
 protected function prepareCndModuleIds(\Doctrine\ORM\QueryBuilder $queryBuilder, $value)
 {
     if (is_array($value) && count($value) > 0) {
         $keys = \XLite\Core\Database::buildInCondition($queryBuilder, $value);
         $queryBuilder->andWhere(sprintf('%s.%s IN (%s)', $this->getMainAlias($queryBuilder), $this->_class->identifier[0], implode(', ', $keys)));
     }
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:15,代码来源:Module.php

示例2: findByIds

 /**
  * Find entities by id's list
  *
  * @param array  $ids    Id's list
  * @param string $prefix Prefix OPTIONAL
  *
  * @return array
  */
 public function findByIds(array $ids, $prefix = 'arr')
 {
     if (1 < count($this->_class->identifier)) {
         // TODO - add throw exception
     }
     $result = array();
     if ($ids) {
         $qb = $this->createQueryBuilder();
         $keys = \XLite\Core\Database::buildInCondition($qb, $ids, $prefix);
         $alias = $this->getMainAlias($qb);
         $qb->andWhere($alias . '.' . $this->_class->identifier[0] . ' IN (' . implode(', ', $keys) . ')');
         $result = $qb->getResult();
     }
     return $result;
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:23,代码来源:ARepo.php

示例3: prepareCndProduct

 /**
  * Prepare certain search condition
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param mixed                      $value        Condition OPTIONAL
  *
  * @return void
  */
 protected function prepareCndProduct(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null)
 {
     if ($value && !is_object($value)) {
         $ids = array();
         foreach ($value as $product) {
             if ($product && is_object($product) && $product->getProductClass()) {
                 $ids[$product->getProductClass()->getId()] = $product->getProductClass()->getId();
             }
         }
         if ($ids) {
             $keys = \XLite\Core\Database::buildInCondition($queryBuilder, $ids, 'pcid');
             $queryBuilder->andWhere('p.id IN (' . implode(', ', $keys) . ')');
         } else {
             $queryBuilder->andWhere('p.id is null');
         }
     }
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:25,代码来源:ProductClass.php

示例4: prepareCndProductClass

 /**
  * Prepare certain search condition
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param mixed                      $value        Condition OPTIONAL
  *
  * @return void
  */
 protected function prepareCndProductClass(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null)
 {
     if (is_null($value)) {
         $queryBuilder->andWhere('a.productClass is null');
     } elseif (is_object($value) && 'Doctrine\\ORM\\PersistentCollection' != get_class($value)) {
         $queryBuilder->andWhere('a.productClass = :productClass')->setParameter('productClass', $value);
     } elseif ($value) {
         $ids = array();
         foreach ($value as $id) {
             if ($id) {
                 $ids[] = is_object($id) ? $id->getId() : $id;
             }
         }
         if ($ids) {
             $keys = \XLite\Core\Database::buildInCondition($queryBuilder, $ids, 'pcid');
             $queryBuilder->linkInner('a.productClass')->andWhere('productClass.id IN (' . implode(', ', $keys) . ')');
         }
     }
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:27,代码来源:Attribute.php

示例5: getInCondition

 /**
  * Get IN () condition
  *
  * @param mixed  $data   Data
  * @param string $prefix Parameter prefix OPTIONAL
  *
  * @return string
  */
 public function getInCondition($data, $prefix = 'id')
 {
     if (is_scalar($data)) {
         $data = array($data);
     } elseif (is_object($data)) {
         if ($data instanceof \Iterator) {
             $tmp = array();
             foreach ($data as $value) {
                 $tmp[] = $value;
             }
             $data = $tmp;
         }
     }
     $keys = \XLite\Core\Database::buildInCondition($this, $data, $prefix);
     return implode(', ', $keys);
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:24,代码来源:AQueryBuilder.php

示例6: getInCondition

 /**
  * Get IN () condition
  * 
  * @param array  $data   Data
  * @param string $prefix Parameter prefix OPTIONAL
  *  
  * @return string
  */
 public function getInCondition(array $data, $prefix = 'id')
 {
     $keys = \XLite\Core\Database::buildInCondition($this, $data, $prefix);
     return implode(', ', $keys);
 }
开发者ID:kingsj,项目名称:core,代码行数:13,代码来源:AQueryBuilder.php

示例7: defineByExceptionIdsQuery

 /**
  * Define query builder for findByExceptionIds() method
  *
  * @param array $exceptionIds Exception ids list
  *
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function defineByExceptionIdsQuery(array $exceptionIds)
 {
     $qb = $this->createQueryBuilder();
     $keys = \XLite\Core\Database::buildInCondition($qb, $exceptionIds);
     return $qb->andWhere('o.exception_id IN (' . implode(', ', $keys) . ')');
 }
开发者ID:kingsj,项目名称:core,代码行数:13,代码来源:OptionException.php

示例8: prepareCndProduct

 /**
  * Prepare certain search condition
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param mixed                      $value        Condition OPTIONAL
  *
  * @return void
  */
 protected function prepareCndProduct(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null)
 {
     if ($value && !is_object($value)) {
         $ids = array();
         foreach ($value as $id) {
             if ($id) {
                 $ids[] = is_object($id) ? $id->getId() : $id;
             }
         }
         if ($ids) {
             $keys = \XLite\Core\Database::buildInCondition($queryBuilder, $ids, 'pid');
             $queryBuilder->linkInner('p.products')->andWhere('products.product_id IN (' . implode(', ', $keys) . ')');
         }
     }
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:23,代码来源:TaxClass.php

示例9: prepareCndPermissions

 /**
  * Search condition by permission(s)
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder QueryBuilder instance
  * @param mixed                      $value        Searchable value
  *
  * @return void
  */
 protected function prepareCndPermissions(\Doctrine\ORM\QueryBuilder $queryBuilder, $value)
 {
     if (!empty($value)) {
         if (!is_array($value)) {
             $value = array($value);
         }
         $keys = \XLite\Core\Database::buildInCondition($queryBuilder, $value, 'perm');
         $queryBuilder->linkInner('p.roles')->linkInner('roles.permissions')->andWhere('permissions.code IN (' . implode(', ', $keys) . ')');
     }
 }
开发者ID:kingsj,项目名称:core,代码行数:18,代码来源:Profile.php


注:本文中的XLite\Core\Database::buildInCondition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。