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


PHP Select::where方法代码示例

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


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

示例1: _addFilter

 /**
  * Add attribute to filter
  *
  * @param int $storeId
  * @param string $attributeCode
  * @param mixed $value
  * @param string $type
  * @return \Magento\Framework\DB\Select|bool
  */
 protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
 {
     if (!$this->_select instanceof \Magento\Framework\DB\Select) {
         return false;
     }
     if (!isset($this->_attributesCache[$attributeCode])) {
         $attribute = $this->_categoryResource->getAttribute($attributeCode);
         $this->_attributesCache[$attributeCode] = ['entity_type_id' => $attribute->getEntityTypeId(), 'attribute_id' => $attribute->getId(), 'table' => $attribute->getBackend()->getTable(), 'is_global' => $attribute->getIsGlobal(), 'backend_type' => $attribute->getBackendType()];
     }
     $attribute = $this->_attributesCache[$attributeCode];
     switch ($type) {
         case '=':
             $conditionRule = '=?';
             break;
         case 'in':
             $conditionRule = ' IN(?)';
             break;
         default:
             return false;
             break;
     }
     if ($attribute['backend_type'] == 'static') {
         $this->_select->where('e.' . $attributeCode . $conditionRule, $value);
     } else {
         $this->_select->join(['t1_' . $attributeCode => $attribute['table']], 'e.entity_id = t1_' . $attributeCode . '.entity_id AND t1_' . $attributeCode . '.store_id = 0', [])->where('t1_' . $attributeCode . '.attribute_id=?', $attribute['attribute_id']);
         if ($attribute['is_global']) {
             $this->_select->where('t1_' . $attributeCode . '.value' . $conditionRule, $value);
         } else {
             $ifCase = $this->getConnection()->getCheckSql('t2_' . $attributeCode . '.value_id > 0', 't2_' . $attributeCode . '.value', 't1_' . $attributeCode . '.value');
             $this->_select->joinLeft(['t2_' . $attributeCode => $attribute['table']], $this->getConnection()->quoteInto('t1_' . $attributeCode . '.entity_id = t2_' . $attributeCode . '.entity_id AND t1_' . $attributeCode . '.attribute_id = t2_' . $attributeCode . '.attribute_id AND t2_' . $attributeCode . '.store_id=?', $storeId), [])->where('(' . $ifCase . ')' . $conditionRule, $value);
         }
     }
     return $this->_select;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:43,代码来源:Category.php

示例2: build

 /**
  * {@inheritdoc}
  */
 public function build(ScoreBuilder $scoreBuilder, Select $select, RequestQueryInterface $query, $conditionType)
 {
     /** @var $query \Magento\Framework\Search\Request\Query\Match */
     $queryValue = $this->prepareQuery($query->getValue(), $conditionType);
     $fieldList = [];
     foreach ($query->getMatches() as $match) {
         $fieldList[] = $match['field'];
     }
     $resolvedFieldList = $this->resolver->resolve($fieldList);
     $fieldIds = [];
     $columns = [];
     foreach ($resolvedFieldList as $field) {
         if ($field->getType() === FieldInterface::TYPE_FULLTEXT && $field->getAttributeId()) {
             $fieldIds[] = $field->getAttributeId();
         }
         $column = $field->getColumn();
         $columns[$column] = $column;
     }
     $matchQuery = $this->fulltextHelper->getMatchQuery($columns, $queryValue, $this->fulltextSearchMode);
     $scoreBuilder->addCondition($matchQuery, true);
     if ($fieldIds) {
         $matchQuery = sprintf('(%s AND search_index.attribute_id IN (%s))', $matchQuery, implode(',', $fieldIds));
     }
     $select->where($matchQuery);
     return $select;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:29,代码来源:Match.php

示例3: _addFilter

 /**
  * Add attribute to filter
  *
  * @param int $storeId
  * @param string $attributeCode
  * @param mixed $value
  * @param string $type
  * @return \Magento\Framework\DB\Select|bool
  */
 protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
 {
     if (!$this->_select instanceof \Magento\Framework\DB\Select) {
         return false;
     }
     switch ($type) {
         case '=':
             $conditionRule = '=?';
             break;
         case 'in':
             $conditionRule = ' IN(?)';
             break;
         default:
             return false;
             break;
     }
     $attribute = $this->_getAttribute($attributeCode);
     if ($attribute['backend_type'] == 'static') {
         $this->_select->where('e.' . $attributeCode . $conditionRule, $value);
     } else {
         $this->_joinAttribute($storeId, $attributeCode);
         if ($attribute['is_global']) {
             $this->_select->where('t1_' . $attributeCode . '.value' . $conditionRule, $value);
         } else {
             $ifCase = $this->getConnection()->getCheckSql('t2_' . $attributeCode . '.value_id > 0', 't2_' . $attributeCode . '.value', 't1_' . $attributeCode . '.value');
             $this->_select->where('(' . $ifCase . ')' . $conditionRule, $value);
         }
     }
     return $this->_select;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:39,代码来源:Product.php

示例4: match

 /**
  * Method for FULLTEXT search in Mysql, will added generated
  * MATCH ($columns) AGAINST ('$expression' $mode) to where clause
  *
  * @param \Magento\Framework\DB\Select $select
  * @param string|string[] $columns Columns which add to MATCH ()
  * @param string $expression Expression which add to AGAINST ()
  * @param bool $isCondition true=AND, false=OR
  * @param string $mode
  * @return \Magento\Framework\DB\Select
  */
 public function match($select, $columns, $expression, $isCondition = true, $mode = self::FULLTEXT_MODE_NATURAL)
 {
     $fullCondition = $this->getMatchQuery($columns, $expression, $mode);
     if ($isCondition) {
         $select->where($fullCondition);
     } else {
         $select->orWhere($fullCondition);
     }
     return $select;
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:21,代码来源:Fulltext.php

示例5: addFieldToFilter

 /**
  * @inheritdoc
  */
 public function addFieldToFilter($field, $condition = null)
 {
     if (is_array($field)) {
         $conditions = [];
         foreach ($field as $key => $value) {
             $conditions[] = $this->translateCondition($value, isset($condition[$key]) ? $condition[$key] : null);
         }
         $resultCondition = '(' . implode(') ' . \Zend_Db_Select::SQL_OR . ' (', $conditions) . ')';
     } else {
         $resultCondition = $this->translateCondition($field, $condition);
     }
     $this->select->where($resultCondition, null, Select::TYPE_CONDITION);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:AbstractMapper.php

示例6: processWhereCondition

 /**
  * Process WHERE clause
  *
  * @param Select $select
  * @return void
  */
 protected function processWhereCondition(Select $select)
 {
     foreach ($this->referenceColumns as $column => $referenceColumn) {
         $identifier = '';
         if (isset($referenceColumn['tableAlias'])) {
             $identifier = $referenceColumn['tableAlias'] . '.';
         }
         $columnName = $column;
         if (isset($referenceColumn['columnName'])) {
             $columnName = $referenceColumn['columnName'];
         }
         $select->where(sprintf('%s = %s', $this->adapter->quoteIdentifier('lookup.' . $column), $this->adapter->quoteIdentifier($identifier . $columnName)));
     }
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:20,代码来源:LookupExpression.php

示例7: prepareSelect

 /**
  * @param \Magento\Framework\DB\Select $select
  * @return \Magento\Framework\DB\Select
  */
 public function prepareSelect(\Magento\Framework\DB\Select $select)
 {
     $select->where('website_id = :website_id')->order(['dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC'])->limit(1);
     // Render destination condition
     $orWhere = '(' . implode(') OR (', ["dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'", "dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'", "dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'"]) . ')';
     $select->where($orWhere);
     // Render condition by condition name
     if (is_array($this->request->getConditionName())) {
         $orWhere = [];
         foreach (range(0, count($this->request->getConditionName())) as $conditionNumber) {
             $bindNameKey = sprintf(':condition_name_%d', $conditionNumber);
             $bindValueKey = sprintf(':condition_value_%d', $conditionNumber);
             $orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
         }
         if ($orWhere) {
             $select->where(implode(' OR ', $orWhere));
         }
     } else {
         $select->where('condition_name = :condition_name');
         $select->where('condition_value <= :condition_value');
     }
     return $select;
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:27,代码来源:RateQuery.php

示例8: _addAttributeToSelect

 /**
  * Add attribute join condition to select and return \Zend_Db_Expr
  * attribute value definition
  * If $condition is not empty apply limitation for select
  *
  * @param \Magento\Framework\DB\Select $select
  * @param string $attrCode              the attribute code
  * @param string|\Zend_Db_Expr $entity   the entity field or expression for condition
  * @param string|\Zend_Db_Expr $store    the store field or expression for condition
  * @param \Zend_Db_Expr $condition       the limitation condition
  * @param bool $required                if required or has condition used INNER join, else - LEFT
  * @return \Zend_Db_Expr                 the attribute value expression
  */
 protected function _addAttributeToSelect($select, $attrCode, $entity, $store, $condition = null, $required = false)
 {
     $attribute = $this->_getAttribute($attrCode);
     $attributeId = $attribute->getAttributeId();
     $attributeTable = $attribute->getBackend()->getTable();
     $connection = $this->getConnection();
     $joinType = $condition !== null || $required ? 'join' : 'joinLeft';
     if ($attribute->isScopeGlobal()) {
         $alias = 'ta_' . $attrCode;
         $select->{$joinType}([$alias => $attributeTable], "{$alias}.entity_id = {$entity} AND {$alias}.attribute_id = {$attributeId}" . " AND {$alias}.store_id = 0", []);
         $expression = new \Zend_Db_Expr("{$alias}.value");
     } else {
         $dAlias = 'tad_' . $attrCode;
         $sAlias = 'tas_' . $attrCode;
         $select->{$joinType}([$dAlias => $attributeTable], "{$dAlias}.entity_id = {$entity} AND {$dAlias}.attribute_id = {$attributeId}" . " AND {$dAlias}.store_id = 0", []);
         $select->joinLeft([$sAlias => $attributeTable], "{$sAlias}.entity_id = {$entity} AND {$sAlias}.attribute_id = {$attributeId}" . " AND {$sAlias}.store_id = {$store}", []);
         $expression = $connection->getCheckSql($connection->getIfNullSql("{$sAlias}.value_id", -1) . ' > 0', "{$sAlias}.value", "{$dAlias}.value");
     }
     if ($condition !== null) {
         $select->where("{$expression}{$condition}");
     }
     return $expression;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:36,代码来源:AbstractIndexer.php

示例9: processDimensions

 /**
  * Add filtering by dimensions
  *
  * @param RequestInterface $request
  * @param Select $select
  * @return \Magento\Framework\DB\Select
  */
 private function processDimensions(RequestInterface $request, Select $select)
 {
     $dimensions = $this->prepareDimensions($request->getDimensions());
     $query = $this->conditionManager->combineQueries($dimensions, Select::SQL_OR);
     if (!empty($query)) {
         $select->where($this->conditionManager->wrapBrackets($query));
     }
     return $select;
 }
开发者ID:nja78,项目名称:magento2,代码行数:16,代码来源:IndexBuilder.php

示例10: applyCondition

 protected function applyCondition(Select $select)
 {
     $select->where('attribute.entity_id IN(?)', $this->entityIds);
 }
开发者ID:EcomDev,项目名称:mysql-performance-benchmark,代码行数:4,代码来源:In.php

示例11: _applyStoresFilterToSelect

 /**
  * Apply stores filter to select object
  *
  * @param \Magento\Framework\DB\Select $select
  * @return $this
  */
 protected function _applyStoresFilterToSelect(\Magento\Framework\DB\Select $select)
 {
     $nullCheck = false;
     $storeIds = $this->_storesIds;
     if (!is_array($storeIds)) {
         $storeIds = [$storeIds];
     }
     $storeIds = array_unique($storeIds);
     if ($index = array_search(null, $storeIds)) {
         unset($storeIds[$index]);
         $nullCheck = true;
     }
     if ($nullCheck) {
         $select->where('store_id IN(?) OR store_id IS NULL', $storeIds);
     } else {
         $select->where('store_id IN(?)', $storeIds);
     }
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:AbstractCollection.php

示例12: processDimensions

    /**
     * Add filtering by dimensions
     *
     * @param RequestInterface $request
     * @param Select $select
     * @return \Magento\Framework\DB\Select
     */
    private function processDimensions(RequestInterface $request, Select $select)
    {
        $dimensions = [];
        foreach ($request->getDimensions() as $dimension) {
            $dimensions[] = $this->dimensionsBuilder->build($dimension);
        }

        $query = $this->conditionManager->combineQueries($dimensions, Select::SQL_OR);
        if (!empty($query)) {
            $select->where($this->conditionManager->wrapBrackets($query));
        }

        return $select;
    }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:21,代码来源:Mapper.php

示例13: applyDate

 /**
  * @param \Magento\Framework\DB\Select $select
  * @param int|string $now
  * @return void
  */
 public function applyDate($select, $now)
 {
     $select->where('from_date is null or from_date <= ?', $now)->where('to_date is null or to_date >= ?', $now);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:9,代码来源:DateApplier.php

示例14: build

 /**
  * {@inheritdoc}
  */
 public function build(ScoreBuilder $scoreBuilder, Select $select, RequestQueryInterface $query, $conditionType)
 {
     /** @var $query \Magento\Framework\Search\Request\Query\Match */
     $fieldList = [];
     foreach ($query->getMatches() as $match) {
         $fieldList[] = $match['field'];
     }
     $resolvedFieldList = $this->resolver->resolve($fieldList);
     $fieldIds = [];
     $columns = [];
     foreach ($resolvedFieldList as $field) {
         if ($field->getType() === FieldInterface::TYPE_FULLTEXT && $field->getAttributeId()) {
             $fieldIds[] = $field->getAttributeId();
         }
         $column = $field->getColumn();
         $columns[$column] = $column;
     }
     $exactMatchQuery = $this->getExactMatchQuery($columns, $query->getValue());
     $scoreQuery = $this->getScoreQuery($columns, $query->getValue());
     $scoreBuilder->addCondition(new \Zend_Db_Expr($scoreQuery), true);
     if ($query->getValue() != $this->queryHelper->singularize($query->getValue())) {
         $scoreQuery = $this->getScoreQuery($columns, $this->queryHelper->singularize($query->getValue()));
         $scoreBuilder->addCondition(new \Zend_Db_Expr($scoreQuery), true);
     }
     if ($fieldIds) {
         $select->where(sprintf('search_index.attribute_id IN (%s)', implode(',', $fieldIds)));
     }
     $select->having(new \Zend_Db_Expr($exactMatchQuery))->group('entity_id');
     return $select;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:33,代码来源:Match.php

示例15: limitFlatActive

 public function limitFlatActive(Select $select, $alias = 'main')
 {
     $select->join(['flat' => $this->getTable('entity_flat')], $alias . '.entity_id = flat.entity_id', []);
     $select->where('flat.scope_id = ?', $this->scope->getId($this->scopeCode));
     $select->where('flat.is_active = ?', 1);
     return $this;
 }
开发者ID:EcomDev,项目名称:mysql-performance-benchmark,代码行数:7,代码来源:AbstractProvider.php


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