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


PHP Varien_Db_Adapter_Interface类代码示例

本文整理汇总了PHP中Varien_Db_Adapter_Interface的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Db_Adapter_Interface类的具体用法?PHP Varien_Db_Adapter_Interface怎么用?PHP Varien_Db_Adapter_Interface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _reindexRootCategory

 /**
  * Reindex all products to root category
  *
  * @param Mage_Core_Model_Store $store
  */
 protected function _reindexRootCategory(Mage_Core_Model_Store $store)
 {
     $selects = $this->_prepareSelectsByRange($this->_getAllProducts($store), 'entity_id', self::RANGE_PRODUCT_STEP);
     foreach ($selects as $select) {
         $this->_connection->query($this->_connection->insertFromSelect($select, $this->_getMainTmpTable(), array('category_id', 'product_id', 'position', 'is_parent', 'store_id', 'visibility'), Varien_Db_Adapter_Interface::INSERT_IGNORE));
     }
 }
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:12,代码来源:Refresh.php

示例2: getOptions

 /**
  * Gets attribute options from database
  *
  * @param \Mage_Eav_Model_Entity_Attribute $attribute
  *
  * @return array
  */
 protected function getOptions($attribute)
 {
     $select = $this->readConnection->select()->from(array('o' => \Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')))->join(array('ov' => \Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value')), 'o.option_id = ov.option_id')->where('o.attribute_id = ?', $attribute->getId())->where('ov.store_id = 0')->order('ov.option_id');
     $query = $select->query();
     $values = array();
     foreach ($query->fetchAll() as $row) {
         $values[] = $row['value'];
     }
     return array('values' => $values);
 }
开发者ID:navarr,项目名称:n98-magerun,代码行数:17,代码来源:AbstractEntityType.php

示例3: getOperatorCondition

 /**
  * Convert operator for sql where
  *
  * @param string $field
  * @param string $operator
  * @param string|array $value
  * @return string
  */
 public function getOperatorCondition($field, $operator, $value)
 {
     switch ($operator) {
         case '!=':
         case '>=':
         case '<=':
         case '>':
         case '<':
             $selectOperator = sprintf('%s?', $operator);
             break;
         case '{}':
         case '!{}':
             if (preg_match('/^.*(category_id)$/', $field) && is_array($value)) {
                 $selectOperator = ' IN (?)';
             } else {
                 $selectOperator = ' LIKE ?';
             }
             if (substr($operator, 0, 1) == '!') {
                 $selectOperator = ' NOT' . $selectOperator;
             }
             break;
         case '[]':
         case '![]':
         case '()':
         case '!()':
             $selectOperator = 'FIND_IN_SET(?,' . $this->_adapter->quoteIdentifier($field) . ')';
             if (substr($operator, 0, 1) == '!') {
                 $selectOperator = 'NOT ' . $selectOperator;
             }
             break;
         default:
             $selectOperator = '=?';
             break;
     }
     $field = $this->_adapter->quoteIdentifier($field);
     if (is_array($value) && in_array($operator, array('==', '!=', '>=', '<=', '>', '<', '{}', '!{}'))) {
         $results = array();
         foreach ($value as $v) {
             $results[] = $this->_adapter->quoteInto("{$field}{$selectOperator}", $v);
         }
         $result = implode(' AND ', $results);
     } elseif (in_array($operator, array('()', '!()', '[]', '![]'))) {
         if (!is_array($value)) {
             $value = array($value);
         }
         $results = array();
         foreach ($value as $v) {
             $results[] = $this->_adapter->quoteInto("{$selectOperator}", $v);
         }
         $result = implode(in_array($operator, array('()', '!()')) ? ' OR ' : ' AND ', $results);
     } else {
         $result = $this->_adapter->quoteInto("{$field}{$selectOperator}", $value);
     }
     return $result;
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:63,代码来源:SqlBuilder.php

示例4: _processTemplates

 /**
  * @param $data
  */
 protected function _processTemplates(&$data)
 {
     $config = $this->_adapter->getConfig();
     $select = $this->_adapter->select();
     $select->from('information_schema.tables', 'AUTO_INCREMENT')->where('table_schema = ?', $config['dbname'])->where('table_name = ?', $this->_adapter->getTableName('customer_entity'));
     $nextId = $this->_adapter->fetchOne($select);
     foreach ($data['account'] as &$field) {
         $field = str_replace('{id}', $nextId, $field);
     }
     foreach ($data['address'] as &$address) {
         foreach ($address as &$field) {
             $field = str_replace('{id}', $nextId, $field);
         }
     }
 }
开发者ID:AnyMarket,项目名称:magento,代码行数:18,代码来源:Customergenerator.php

示例5: truncateResourceGroups

 /**
  * Loop through resource groups and truncate tables
  *
  * @return void
  */
 protected function truncateResourceGroups()
 {
     foreach ($this->groups as $name => $resources) {
         $this->prepareResources($resources);
         if (!count($resources)) {
             continue;
         }
         array_walk($resources, array($this, 'prepareArrayForTableOutput'));
         if (!$this->force) {
             $this->output->writeln(sprintf('<info>%s</info> table(s):', $name));
             $table = new Table($this->output);
             $table->setRows($resources)->render();
             $confirm = $this->dialog->askConfirmation($this->output, '<question>Truncate table(s)?</question> ', false);
             if (!$confirm) {
                 continue;
             }
         }
         foreach ($resources as $resourceName) {
             if (!$resourceName[0]) {
                 continue;
             }
             $this->dbWrite->truncateTable($resourceName[0]);
             $this->output->writeln(sprintf('Truncate <info>%s</info>', $resourceName[0]));
         }
     }
 }
开发者ID:steverobbins,项目名称:Magerun-DBClean,代码行数:31,代码来源:CleanCommand.php

示例6: getAttributeCodes

 /**
  * Retrieve attribute codes using for flat
  *
  * @return array
  */
 public function getAttributeCodes()
 {
     if ($this->_attributeCodes === null) {
         $this->_attributeCodes = array();
         $systemAttributes = array();
         $attributeNodes = Mage::getConfig()->getNode(self::XML_NODE_ATTRIBUTE_NODES)->children();
         foreach ($attributeNodes as $node) {
             $attributes = Mage::getConfig()->getNode((string) $node)->asArray();
             $attributes = array_keys($attributes);
             $systemAttributes = array_unique(array_merge($attributes, $systemAttributes));
         }
         $bind = array('backend_type' => Mage_Eav_Model_Entity_Attribute_Abstract::TYPE_STATIC, 'entity_type_id' => $this->getEntityTypeId());
         $select = $this->_connection->select()->from(array('main_table' => $this->getTable('eav/attribute')))->join(array('additional_table' => $this->getTable('catalog/eav_attribute')), 'additional_table.attribute_id = main_table.attribute_id')->where('main_table.entity_type_id = :entity_type_id');
         $whereCondition = array('main_table.backend_type = :backend_type', $this->_connection->quoteInto('additional_table.is_used_for_promo_rules = ?', 1), $this->_connection->quoteInto('additional_table.used_in_product_listing = ?', 1), $this->_connection->quoteInto('additional_table.used_for_sort_by = ?', 1), $this->_connection->quoteInto('main_table.attribute_code IN(?)', $systemAttributes));
         if ($this->getFlatHelper()->isAddFilterableAttributes()) {
             $whereCondition[] = $this->_connection->quoteInto('additional_table.is_filterable > ?', 0);
         }
         $select->where(implode(' OR ', $whereCondition));
         $attributesData = $this->_connection->fetchAll($select, $bind);
         Mage::getSingleton('eav/config')->importAttributesData($this->getEntityType(), $attributesData);
         foreach ($attributesData as $data) {
             $this->_attributeCodes[$data['attribute_id']] = $data['attribute_code'];
         }
         unset($attributesData);
     }
     return $this->_attributeCodes;
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:32,代码来源:Product.php

示例7: testInsertForce

 /**
  * @dataProvider insertDataProvider
  */
 public function testInsertForce($data)
 {
     $this->assertEquals(1, $this->_connection->insertForce($this->_tableName, $data));
     $select = $this->_connection->select()->from($this->_tableName);
     $result = $this->_connection->fetchRow($select);
     $this->assertEquals($data, $result);
 }
开发者ID:nemphys,项目名称:magento2,代码行数:10,代码来源:InterfaceTest.php

示例8: testReadEncoded

 /**
  * Assert that session data reads from DB correctly regardless of encoding
  *
  * @param string $sessionData
  *
  * @dataProvider readEncodedDataProvider
  */
 public function testReadEncoded($sessionData)
 {
     $sessionRecord = array(self::COLUMN_SESSION_ID => self::SESSION_ID, self::COLUMN_SESSION_DATA => $sessionData);
     $this->_connection->insertOnDuplicate($this->_sessionTable, $sessionRecord, array(self::COLUMN_SESSION_DATA));
     $sessionData = $this->_model->read(self::SESSION_ID);
     $this->assertEquals($this->_sourceData[self::SESSION_NEW], unserialize($sessionData));
 }
开发者ID:natxetee,项目名称:magento2,代码行数:14,代码来源:SessionTest.php

示例9: _wrapBodyWithCond

 /**
  * Wrap trigger body with conditions
  *
  * @param string $body
  * @param array $conditions
  * @param string $conditionsLogic
  * @return string
  */
 protected function _wrapBodyWithCond($body, $conditions = array(), $conditionsLogic = Zend_Db_Select::SQL_OR)
 {
     if (empty($conditions)) {
         return $body;
     }
     return $this->_connection->getCaseSql($this->getEventConditionsSql($conditions, $conditionsLogic), array('TRUE' => new Zend_Db_Expr('BEGIN ' . $body . ' END;')), new Zend_Db_Expr('BEGIN END;')) . " CASE;";
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:15,代码来源:Trigger.php

示例10: _prepareAffectedProduct

 /**
  * Prepare affected product
  */
 protected function _prepareAffectedProduct()
 {
     /** @var $modelCondition Mage_Catalog_Model_Product_Condition */
     $modelCondition = $this->_factory->getModel('catalog/product_condition');
     $productCondition = $modelCondition->setTable($this->_resource->getTable('catalogrule/affected_product'))->setPkFieldName('product_id');
     $this->_app->dispatchEvent('catalogrule_after_apply', array('product' => $this->_getProduct(), 'product_condition' => $productCondition));
     $this->_connection->delete($this->_resource->getTable('catalogrule/affected_product'));
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:11,代码来源:Refresh.php

示例11: _getKeyColumnConfig

 /**
  * Returns column definition for column provided in key_column parameter.
  *
  * @return array
  * @throws Enterprise_Mview_Exception
  */
 protected function _getKeyColumnConfig()
 {
     $describe = $this->_table->describe();
     if (!array_key_exists($this->_metadata->getKeyColumn(), $describe)) {
         throw new Enterprise_Mview_Exception(sprintf("Column '%s' does not exist in the '%s' table", $this->_metadata->getKeyColumn(), $this->_table->getObjectName()));
     }
     return $this->_connection->getColumnCreateByDescribe($describe[$this->_metadata->getKeyColumn()]);
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:14,代码来源:Create.php

示例12: _getCurrentVersionId

 /**
  * Get current DB version
  *
  * @return int
  */
 protected function _getCurrentVersionId()
 {
     if (empty($this->_currentVersionId)) {
         // zend select query permanently requires FROM statement, so executing raw query
         $this->_currentVersionId = $this->_connection->query($this->_connection->select()->from($this->_metadata->getChangelogName(), array())->columns(array('max' => 'MAX(version_id)')))->fetchColumn();
     }
     return $this->_currentVersionId;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:13,代码来源:RefreshAbstract.php

示例13: _selectLastVersionId

 /**
  * Returns last version_id from changelog table
  *
  * @return int
  */
 protected function _selectLastVersionId()
 {
     $changelogName = $this->_metadata->getChangelogName();
     if (empty($changelogName)) {
         return 0;
     }
     $select = $this->_connection->select()->from(array('changelog' => $changelogName), array('version_id'))->order('version_id DESC')->limit(1);
     return (int) $this->_connection->fetchOne($select);
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:14,代码来源:Refresh.php

示例14: _refreshSpecialPriceByStore

 /**
  * Add products to changelog by conditions
  *
  * @param int $storeId
  * @param string $attrCode
  * @param Zend_Db_Expr $attrConditionValue
  */
 protected function _refreshSpecialPriceByStore($storeId, $attrCode, $attrConditionValue)
 {
     $attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attrCode);
     $attributeId = $attribute->getAttributeId();
     $select = $this->_connection->select()->from($this->_getTable(array('catalog/product', 'datetime')), array('entity_id'))->where('attribute_id = ?', $attributeId)->where('store_id = ?', $storeId)->where('value = ?', $attrConditionValue);
     $client = $this->_getClient(Mage::helper('enterprise_index')->getIndexerConfigValue('catalog_product_price', 'index_table'));
     $query = $select->insertFromSelect($client->getMetadata()->changelog_name, array('entity_id'), false);
     $this->_connection->query($query);
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:16,代码来源:Price.php

示例15: _getCategorySeoSuffixCaseSql

 /**
  * Get case sql for define category seo suffix by store
  *
  * @param string $field
  *
  * @return Zend_Db_Expr
  */
 protected function _getCategorySeoSuffixCaseSql($field)
 {
     /* @var $store Mage_Core_Model_Store */
     foreach ($this->_app->getStores() as $store) {
         $seoSuffix = $this->_categoryHelper->getCategoryUrlSuffix($store->getId());
         $casesResults[$store->getId()] = !empty($seoSuffix) ? '".' . $seoSuffix . '"' : '""';
     }
     return $this->_connection->getCaseSql($field, $casesResults);
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:16,代码来源:Redirect.php


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