本文整理汇总了PHP中Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::getSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractCollection::getSelect方法的具体用法?PHP AbstractCollection::getSelect怎么用?PHP AbstractCollection::getSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
的用法示例。
在下文中一共展示了AbstractCollection::getSelect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addIsUsedFilterCallback
/**
* Callback function that filters collection by field "Used" from grid
*
* @param AbstractCollection $collection
* @param Column $column
* @return void
*/
public function addIsUsedFilterCallback($collection, $column)
{
$filterValue = $column->getFilter()->getCondition();
$expression = $this->getConnection()->getCheckSql('main_table.times_used > 0', 1, 0);
$conditionSql = $this->_getConditionSql($expression, $filterValue);
$collection->getSelect()->where($conditionSql);
}
示例2: _prepareCache
/**
* @param \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection $collection
*/
protected function _prepareCache($collection)
{
$stmt = $collection->getSelect()->query();
$ids = array();
foreach ($stmt as $item) {
$ids = array_merge($ids, array_map('intval', explode('/', $item['path'])));
}
$ids = array_unique($ids);
if (empty($ids)) {
return;
}
/* @var $attribute \Magento\Eav\Model\Attribute */
$attribute = $collection->getFirstItem()->getResource()->getAttribute('name');
$resource = $collection->getResource();
$tableName = \Magento\Catalog\Model\Category::ENTITY . '_entity_' . $attribute->getBackendType();
$dbSelect1 = $resource->getConnection()->select()->from($resource->getTable($tableName), new \Zend_Db_Expr('MAX(`store_id`)'))->where("`entity_id` = `ccev`.`entity_id`")->where("`attribute_id` = `ccev`.`attribute_id`")->where("`store_id` = 0 OR `store_id` = ?", $this->getStoreId());
$dbSelect2 = $resource->getConnection()->select()->from(array('ccev' => $resource->getTable($tableName)), array('name' => 'value', 'category_id' => 'entity_id'))->where('ccev.entity_id IN (' . implode(',', $ids) . ')')->where('ccev.attribute_id = ?', $attribute->getAttributeId())->where('ccev.store_id = (' . $dbSelect1->__toString() . ')');
$cacheData = array();
foreach ($resource->getConnection()->fetchAll($dbSelect2) as $row) {
$cacheData[$row['category_id']] = $row['name'];
}
$this->setData('categories_cache', $cacheData);
}
示例3: testGetAllIdsWithBind
public function testGetAllIdsWithBind()
{
$this->_model->getSelect()->where('code = :code');
$this->_model->addBindParam('code', 'admin');
$this->assertEquals(['0'], $this->_model->getAllIds());
}