本文整理汇总了PHP中Magento\Framework\DB\Adapter\AdapterInterface::fetchCol方法的典型用法代码示例。如果您正苦于以下问题:PHP AdapterInterface::fetchCol方法的具体用法?PHP AdapterInterface::fetchCol怎么用?PHP AdapterInterface::fetchCol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DB\Adapter\AdapterInterface
的用法示例。
在下文中一共展示了AdapterInterface::fetchCol方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doesEntityHaveOverriddenUrlKeyForStore
/**
* Check that entity has overridden url key for specific store
*
* @param int $storeId
* @param int $entityId
* @param string $entityType
* @throws \InvalidArgumentException
* @return bool
*/
public function doesEntityHaveOverriddenUrlKeyForStore($storeId, $entityId, $entityType)
{
$attribute = $this->eavConfig->getAttribute($entityType, 'url_key');
if (!$attribute) {
throw new \InvalidArgumentException(sprintf('Cannot retrieve attribute for entity type "%s"', $entityType));
}
$select = $this->connection->select()->from($attribute->getBackendTable(), 'store_id')->where('attribute_id = ?', $attribute->getId())->where('entity_id = ?', $entityId);
return in_array($storeId, $this->connection->fetchCol($select));
}
示例2: doesEntityHaveOverriddenUrlAttributeForStore
/**
* Check that entity has overridden url attribute for specific store
*
* @param int $storeId
* @param int $entityId
* @param string $entityType
* @param mixed $attributeName
* @throws \InvalidArgumentException
* @return bool
*/
protected function doesEntityHaveOverriddenUrlAttributeForStore($storeId, $entityId, $entityType, $attributeName)
{
$attribute = $this->eavConfig->getAttribute($entityType, $attributeName);
if (!$attribute) {
throw new \InvalidArgumentException(sprintf('Cannot retrieve attribute for entity type "%s"', $entityType));
}
$linkFieldName = $attribute->getEntity()->getLinkField();
if (!$linkFieldName) {
$linkFieldName = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
}
$select = $this->connection->select()->from(['e' => $attribute->getEntity()->getEntityTable()], [])->join(['e_attr' => $attribute->getBackendTable()], "e.{$linkFieldName} = e_attr.{$linkFieldName}", 'store_id')->where('e_attr.attribute_id = ?', $attribute->getId())->where('e.entity_id = ?', $entityId);
return in_array($storeId, $this->connection->fetchCol($select));
}
示例3: getList
/**
* Retrieve entity ids by range [$fromVersionId..$toVersionId]
*
* @param int $fromVersionId
* @param int $toVersionId
* @return int[]
* @throws \Exception
*/
public function getList($fromVersionId, $toVersionId)
{
$changelogTableName = $this->resource->getTableName($this->getName());
if (!$this->connection->isTableExists($changelogTableName)) {
throw new \Exception("Table {$changelogTableName} does not exist");
}
$select = $this->connection->select()->distinct(true)->from($changelogTableName, [$this->getColumnName()])->where('version_id > ?', (int) $fromVersionId)->where('version_id <= ?', (int) $toVersionId);
return $this->connection->fetchCol($select);
}
示例4: loadDeletedRecords
/**
* @inheritdoc
*/
public function loadDeletedRecords($deltaLogName, $idKey, $pageNumber, $pageSize, $getProcessed = false)
{
$select = $this->resourceAdapter->select();
$select->from($deltaLogName, [$idKey])->where("`operation` = 'DELETE'")->limit($pageSize, $pageNumber * $pageSize);
if (!$getProcessed) {
$select->where("`processed` != 1");
}
$result = $this->resourceAdapter->fetchCol($select);
return $result;
}
示例5: _updateChildLevels
/**
* @param mixed $parentId
* @param int $parentLevel
* @return $this
*/
protected function _updateChildLevels($parentId, $parentLevel)
{
$select = $this->_conn->select()->from($this->_table, $this->_idField)->where($this->_parentField . '=?', $parentId);
$ids = $this->_conn->fetchCol($select);
if (!empty($ids)) {
$this->_conn->update($this->_table, [$this->_levelField => $parentLevel + 1], $this->_conn->quoteInto($this->_idField . ' IN (?)', $ids));
foreach ($ids as $id) {
$this->_updateChildLevels($id, $parentLevel + 1);
}
}
return $this;
}
示例6: getProductChildIds
/**
* Return all product children ids
*
* @param int $productId Product Entity Id
* @param string $typeId Super Product Link Type
* @return array|null
*/
public function getProductChildIds($productId, $typeId)
{
$typeInstance = $this->getProductTypeInstance($typeId);
$relation = $typeInstance->isComposite($this->getProductEmulator($typeId)) ? $typeInstance->getRelationInfo() : false;
if ($relation && $relation->getTable() && $relation->getParentFieldName() && $relation->getChildFieldName()) {
$select = $this->connection->select()->from(['main' => $this->getTable($relation->getTable())], [$relation->getChildFieldName()])->where($relation->getParentFieldName() . ' = ?', $productId);
if ($relation->getWhere() !== null) {
$select->where($relation->getWhere());
}
return $this->connection->fetchCol($select);
}
return null;
}
示例7: getProductChildIds
/**
* Return all product children ids
*
* @param int $productId Product Entity Id
* @param string $typeId Super Product Link Type
* @return array|null
*/
public function getProductChildIds($productId, $typeId)
{
$typeInstance = $this->getProductTypeInstance($typeId);
$relation = $typeInstance->isComposite($this->getProductEmulator($typeId)) ? $typeInstance->getRelationInfo() : false;
if ($relation && $relation->getTable() && $relation->getParentFieldName() && $relation->getChildFieldName()) {
$select = $this->connection->select()->from(['main' => $this->getTable($relation->getTable())], [$relation->getChildFieldName()]);
$select->join(['e' => $this->resource->getTableName('catalog_product_entity')], 'e.' . $this->metadata->getLinkField() . ' = main.' . $relation->getParentFieldName())->where('e.entity_id = ?', $productId);
if ($relation->getWhere() !== null) {
$select->where($relation->getWhere());
}
return $this->connection->fetchCol($select);
}
return null;
}
示例8: _copyRelationIndexData
/**
* Copy relations product index from primary index to temporary index table by parent entity
*
* @param null|array $parentIds
* @param array $excludeIds
* @return \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction
*/
protected function _copyRelationIndexData($parentIds, $excludeIds = null)
{
$select = $this->_connection->select()->from($this->_defaultIndexerResource->getTable('catalog_product_relation'), ['child_id'])->where('parent_id IN(?)', $parentIds);
if (!empty($excludeIds)) {
$select->where('child_id NOT IN(?)', $excludeIds);
}
$children = $this->_connection->fetchCol($select);
if ($children) {
$select = $this->_connection->select()->from($this->_defaultIndexerResource->getTable('catalog_product_index_price'))->where('entity_id IN(?)', $children);
$query = $select->insertFromSelect($this->_defaultIndexerResource->getIdxTable(), [], false);
$this->_connection->query($query);
}
return $this;
}
示例9: isNeedCreateUrlRewrite
/**
* If product saved on default store view, then need to check specific url_key for other stores
*
* @param int $storeId
* @param int $productId
* @return bool
*/
public function isNeedCreateUrlRewrite($storeId, $productId)
{
$attribute = $this->eavConfig->getAttribute(Product::ENTITY, 'url_key');
$select = $this->connection->select()->from($attribute->getBackendTable(), 'store_id')->where('attribute_id = ?', $attribute->getId())->where('entity_id = ?', $productId);
return !in_array($storeId, $this->connection->fetchCol($select));
}
示例10: getAffectedAttributeIds
/**
* @param AdapterInterface $connection
* @param string $attributeTableName
* @return array
* @throws \Zend_Db_Statement_Exception
*/
private function getAffectedAttributeIds(AdapterInterface $connection, $attributeTableName)
{
$linkField = $this->metadata->getLinkField();
$select = $connection->select()->reset();
$select->from(['e' => $this->attributeResource->getTable('catalog_product_entity')], 'ei.value_id');
$select->join(['ei' => $attributeTableName], 'ei.' . $linkField . ' = e.' . $linkField . ' AND ei.store_id != 0', '');
$select->join(['s' => $this->attributeResource->getTable('store')], 's.store_id = ei.store_id', '');
$select->join(['sg' => $this->attributeResource->getTable('store_group')], 'sg.group_id = s.group_id', '');
$select->joinLeft(['pw' => $this->attributeResource->getTable('catalog_product_website')], 'pw.website_id = sg.website_id AND pw.product_id = e.entity_id', '');
$select->where('pw.product_id is null');
return $connection->fetchCol($select);
}
示例11: getIsAttributeValueUsed
protected function getIsAttributeValueUsed($attribute_code, $value, $storeId, $isSelect = false)
{
$attributeModel = $this->shipperDataHelper->getAttribute($attribute_code, $storeId);
$select = $this->connection->select()->distinct(true)->from($attributeModel->getBackend()->getTable(), ['value'])->where('attribute_id=?', $attributeModel->getId())->where('value!=?', '');
$usedAttributeValues = $this->connection->fetchCol($select);
if ($isSelect) {
//account for multiselect values
$separated = array();
foreach ($usedAttributeValues as $key => $aValue) {
if (strstr($aValue, ',')) {
$values = explode(',', $aValue);
$separated = array_merge($separated, $values);
unset($usedAttributeValues[$key]);
}
}
$usedAttributeValues = array_merge($usedAttributeValues, $separated);
}
return in_array($value, $usedAttributeValues);
}