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


PHP Varien_Data_Collection_Db::addFieldToFilter方法代码示例

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


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

示例1: testAddFieldToFilterValueContainsQuestionMark

 /**
  * Test that adding field to filter by value which contains question mark produce correct SQL
  */
 public function testAddFieldToFilterValueContainsQuestionMark()
 {
     $adapter = $this->_getAdapterMock('Zend_Db_Adapter_Pdo_Mysql', array('select', 'prepareSqlCondition', 'supportStraightJoin'), null);
     $adapter->expects($this->once())->method('prepareSqlCondition')->with('email', array('like' => 'value?'))->will($this->returnValue('email LIKE \'%value?%\''));
     $adapter->expects($this->once())->method('select')->will($this->returnValue(new Varien_Db_Select($adapter)));
     $this->_collection->setConnection($adapter);
     $select = $this->_collection->getSelect()->from('test');
     $this->_collection->addFieldToFilter('email', array('like' => 'value?'));
     $this->assertEquals("SELECT `test`.* FROM `test` WHERE (email LIKE '%value?%')", $select->assemble());
 }
开发者ID:nemphys,项目名称:magento2,代码行数:13,代码来源:DbTest.php

示例2: testAddFieldToFilterFieldIsQuoted

 /**
  * Test that field is quoted when added to SQL via addFieldToFilter()
  */
 public function testAddFieldToFilterFieldIsQuoted()
 {
     $adapter = $this->getMock('Zend_Db_Adapter_Pdo_Mysql', array('quoteIdentifier', 'prepareSqlCondition'), array(), '', false);
     $adapter->expects($this->once())->method('quoteIdentifier')->with('email')->will($this->returnValue('`email`'));
     $adapter->expects($this->any())->method('prepareSqlCondition')->with($this->stringContains('`email`'), $this->anything())->will($this->returnValue('`email` = "foo@example.com"'));
     $this->_collection->setConnection($adapter);
     $select = $this->_collection->getSelect()->from('test');
     $this->_collection->addFieldToFilter('email', array('eq' => 'foo@example.com'));
     $this->assertEquals('SELECT `test`.* FROM `test` WHERE (`email` = "foo@example.com")', $select->assemble());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:13,代码来源:DbTest.php

示例3: callbackFilterItems

 protected function callbackFilterItems(Varien_Data_Collection_Db $collection, $column)
 {
     $value = $column->getFilter()->getValue();
     if ($value == null) {
         return;
     }
     /** @var $orderItemsCollection Varien_Data_Collection_Db */
     $orderItemsCollection = Mage::helper('M2ePro/Component_Buy')->getCollection('Order_Item');
     $orderItemsCollection->getSelect()->reset(Zend_Db_Select::COLUMNS);
     $orderItemsCollection->getSelect()->columns('order_id');
     $orderItemsCollection->getSelect()->distinct(true);
     $orderItemsCollection->getSelect()->where('general_id LIKE ? OR sku LIKE ? OR title LIKE ?', '%' . $value . '%');
     $ordersIds = $orderItemsCollection->getColumnValues('order_id');
     $collection->addFieldToFilter('`main_table`.id', array('in' => $ordersIds));
 }
开发者ID:newedge-media,项目名称:iwantmymeds,代码行数:15,代码来源:Grid.php

示例4: unlinkEmails

 /**
  * Remove Bronto Message Connection for Template
  *
  * @param Varien_Data_Collection_Db $collection
  * @param string                    $scope
  * @param string|int                $scopeId
  */
 public function unlinkEmails(Varien_Data_Collection_Db $collection, $scope, $scopeId)
 {
     switch ($scope) {
         case 'stores':
         case 'store':
             $storeId = $scopeId;
             break;
         case 'websites':
         case 'website':
             $storeId = Mage::app()->getWebsite($scopeId)->getStoreIds();
             break;
         default:
             $storeId = false;
             break;
     }
     // create filter
     if ($storeId) {
         if (is_array($storeId)) {
             $filter = array('in' => $storeId);
         } else {
             $filter = array('eq' => $storeId);
         }
         $collection->addFieldToFilter('store_id', $filter);
     }
     // Delete Bronto Message connection to template
     foreach ($collection as $message) {
         $message->delete();
     }
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:36,代码来源:Keysentry.php

示例5: callbackFilterMotorsSpecificsAttribute

 public function callbackFilterMotorsSpecificsAttribute(Varien_Data_Collection_Db $collection, $column)
 {
     $value = $column->getFilter()->getValue();
     if ($value == null) {
         return;
     }
     if (!$this->motorsSpecificsAttribute) {
         return;
     }
     $attributeCode = $this->motorsSpecificsAttribute->getAttributeCode();
     if ($value == 1) {
         $collection->addFieldToFilter($attributeCode, array('notnull' => true));
         $collection->addFieldToFilter($attributeCode, array('neq' => '\'\''));
         $collection->addFieldToFilter('is_motors_attribute_in_product_attribute_set', array('notnull' => true));
     } else {
         $collection->addFieldToFilter(array(array('attribute' => $attributeCode, 'null' => true), array('attribute' => $attributeCode, 'eq' => '\'\''), array('attribute' => 'is_motors_attribute_in_product_attribute_set', 'null' => true)));
     }
 }
开发者ID:technomagegithub,项目名称:magento,代码行数:18,代码来源:Grid.php

示例6: callbackFilterMotorsAttribute

 public function callbackFilterMotorsAttribute(Varien_Data_Collection_Db $collection, $column)
 {
     $value = $column->getFilter()->getValue();
     if (is_null($value)) {
         return;
     }
     if (!$this->motorsAttribute) {
         return;
     }
     if ($value == 1) {
         $attributeCode = $this->motorsAttribute->getAttributeCode();
         $collection->addFieldToFilter($attributeCode, array('notnull' => true));
         $collection->addFieldToFilter($attributeCode, array('neq' => ''));
         $collection->addFieldToFilter('is_motors_attribute_in_product_attribute_set', array('notnull' => true));
     } else {
         $attributeId = $this->motorsAttribute->getId();
         $storeId = $this->getListing()->getStoreId();
         $joinCondition = 'eaa.entity_id = e.entity_id and eaa.attribute_id = ' . $attributeId;
         if (!$this->motorsAttribute->isScopeGlobal()) {
             $joinCondition .= ' and eaa.store_id = ' . $storeId;
         }
         $collection->getSelect()->joinLeft(array('eaa' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')), $joinCondition, array('value'));
         $collection->getSelect()->orWhere('eaa.value IS NULL');
         $collection->getSelect()->orWhere('eaa.value = \'\'');
         $collection->getSelect()->orWhere('eea.entity_attribute_id IS NULL');
     }
 }
开发者ID:ReeceCrossland,项目名称:essua-m2epro,代码行数:27,代码来源:Grid.php

示例7: addFieldToFilter

 /**
  * Filter by customer ID, as 'type' field does not exist
  *
  * @param string $fieldName
  * @param array $condition
  * @return Mage_Log_Model_Mysql4_Visitor_Collection
  */
 public function addFieldToFilter($fieldName, $condition = null)
 {
     if ($fieldName == 'type' && is_array($condition) && isset($condition['eq'])) {
         $fieldName = 'customer_id';
         if ($condition['eq'] === Mage_Log_Model_Visitor::VISITOR_TYPE_VISITOR) {
             $condition = array('null' => 1);
         } else {
             $condition = array('moreq' => 1);
         }
     }
     return parent::addFieldToFilter($this->_getFieldMap($fieldName), $condition);
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:19,代码来源:Mysql4_Visitor_Collection.php

示例8: addFieldToFilter

 public function addFieldToFilter($fieldName, $fieldValue = null)
 {
     if ($fieldName == 'type') {
         if ($fieldValue == 'v') {
             return parent::addFieldToFilter('customer_id', array('null' => 1));
         } else {
             return parent::addFieldToFilter('customer_id', array('moreq' => 1));
         }
     } else {
         return parent::addFieldToFilter($fieldName, $fieldValue);
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:12,代码来源:Collection.php

示例9: callbackFilterPartsCompatibilityAttribute

 public function callbackFilterPartsCompatibilityAttribute(Varien_Data_Collection_Db $collection, $column)
 {
     $value = $column->getFilter()->getValue();
     if ($value == null) {
         return;
     }
     if (!$this->partsCompatibilityAttribute) {
         return;
     }
     if ($value == 1) {
         $attributeCode = $this->partsCompatibilityAttribute->getAttributeCode();
         $collection->addFieldToFilter($attributeCode, array('notnull' => true));
         $collection->addFieldToFilter($attributeCode, array('neq' => '\'\''));
         $collection->addFieldToFilter('is_parts_compatibility_attribute_in_product_attribute_set', array('notnull' => true));
     } else {
         $attributeId = $this->partsCompatibilityAttribute->getId();
         $storeId = $this->getListing()->getStoreId();
         $collection->getSelect()->joinLeft(array('eaa' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')), 'eaa.entity_id = e.entity_id and eaa.attribute_id = ' . $attributeId . ' and eaa.store_id = ' . $storeId);
         $collection->getSelect()->orWhere('eaa.value IS NULL');
         $collection->getSelect()->orWhere('eaa.value = \'\'');
         $collection->getSelect()->orWhere('eea.entity_attribute_id IS NULL');
     }
 }
开发者ID:ashfaqphplhr,项目名称:artificiallawnsforturf,代码行数:23,代码来源:Grid.php


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