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


PHP Mage_Core_Model_Abstract::getResource方法代码示例

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


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

示例1: checkModel

 protected function checkModel()
 {
     $this->_mageModel = \Mage::getModel($this->_input->getArgument('modelName'));
     if (true === empty($this->_mageModel)) {
         throw new \InvalidArgumentException('Model ' . $this->_input->getArgument('modelName') . ' not found!');
     }
     $this->_mageModelTable = $this->_mageModel->getResource() ? $this->_mageModel->getResource()->getMainTable() : null;
     if (true === empty($this->_mageModelTable)) {
         throw new \InvalidArgumentException('Cannot find main table of model ' . $this->_input->getArgument('modelName'));
     }
 }
开发者ID:iMi-digital,项目名称:imi-conrun,代码行数:11,代码来源:MethodCommand.php

示例2: factory

 /**
  *
  * @param Mage_Core_Model_Abstract $model
  * @return Magelog_Mql_Model_Model_Description
  */
 public static function factory(Mage_Core_Model_Abstract $model)
 {
     $resource = $model->getResource();
     if ($resource instanceof Mage_Eav_Model_Entity_Abstract) {
         $description = Mage::getModel('mql/model_description_eav');
     } else {
         if ($resource instanceof Mage_Core_Model_Resource_Abstract) {
             $description = Mage::getModel('mql/model_description_flat');
         } else {
             throw new InvalidArgumentException(get_class($model) . ' is not a resource model');
         }
     }
     return $description->setModel($model);
 }
开发者ID:hnesk,项目名称:Magelog_Mql,代码行数:19,代码来源:Description.php

示例3: loadDbColumns

 public function loadDbColumns(Mage_Core_Model_Abstract $model, $ids, $fields, $extraCondition = '')
 {
     self::_transport(true);
     $this->_prepareResourceData($model->getResource(), $ids, array_flip($fields), $fields);
     $idFieldWithValue = self::_getMetaData('id');
     $table = self::_getMetaData('table');
     $preparedData = self::_getMetaData('data');
     $preparedFields = array_keys($preparedData);
     reset($idFieldWithValue);
     $_idField = key($idFieldWithValue);
     $_idValue = current($idFieldWithValue);
     $excludeIdField = false;
     if (!in_array($_idField, $preparedFields)) {
         $preparedFields[] = $_idField;
         $excludeIdField = true;
     }
     $condition = $this->_getWriteAdapter()->quoteInto($_idField . ' in (?)', $_idValue);
     $loadSel = $this->_getWriteAdapter()->select()->from($table, $preparedFields)->where($condition);
     if (!empty($extraCondition)) {
         $extraCondition = str_replace('{{table}}', $table, $extraCondition);
         $loadSel->where($extraCondition);
     }
     $result = array();
     $data = $this->_getWriteAdapter()->fetchAll($loadSel);
     if (is_array($data) && !empty($data)) {
         foreach ($data as $tmp) {
             $__idValue = $tmp[$_idField];
             $result[$__idValue] = $tmp;
             if ($excludeIdField) {
                 unset($result[$__idValue][$_idField]);
             }
         }
     }
     self::_transport(true);
     return $result;
 }
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:36,代码来源:Helper.php

示例4: _saveModel

 protected function _saveModel(Mage_Core_Model_Abstract $model)
 {
     $resource = $model->getResource();
     $adapter = $this->_getWriteConnection();
     if ($model->getId()) {
         $condition = $adapter->quoteInto($resource->getIdFieldName() . '=?', $model->getId());
         $adapter->update($resource->getMainTable(), $model->getData(), $condition);
     } else {
         $adapter->insert($resource->getMainTable(), $model->getData());
     }
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:11,代码来源:Store.php

示例5: getResource

 /**
  * Retrieve resource model wraper
  *
  * @return Mage_CatalogInventory_Model_Mysql4_Stock_Status
  */
 public function getResource()
 {
     return parent::getResource();
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:9,代码来源:Status.php

示例6: _afterSave

 /**
  * Set store data after saving model
  *
  * @param Mage_Core_Model_Abstract $object
  * @return $this
  */
 protected function _afterSave(Mage_Core_Model_Abstract $object)
 {
     if ($object->getId()) {
         $oldStores = $this->lookupStoreIds($object->getId());
         $newStores = (array) $object->getStoreIds();
         if (empty($newStores)) {
             $newStores = (array) $object->getStoreId();
         }
         $table = $this->getStoreTable();
         $insert = array_diff($newStores, $oldStores);
         $delete = array_diff($oldStores, $newStores);
         if ($delete) {
             $this->_getWriteAdapter()->delete($table, array($this->getIdFieldName() . ' = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete));
         }
         if ($insert) {
             $data = array();
             foreach ($insert as $storeId) {
                 $data[] = array($this->getIdFieldName() => (int) $object->getId(), 'store_id' => (int) $storeId);
             }
             $this->_getWriteAdapter()->insertMultiple($table, $data);
         }
         if (!$object->getSkipReindex()) {
             $object->getResource()->reindexAll();
         }
     }
 }
开发者ID:Benjamin021,项目名称:magento-attribute-page,代码行数:32,代码来源:Abstract.php

示例7: _loadDbColumns

 protected function _loadDbColumns(Mage_Core_Model_Abstract $model, $ids, $fields, $extraCondition = '', $forUpdate = false)
 {
     self::_transport(true);
     $this->_prepareResourceData($model->getResource(), $ids, array_flip($fields), $fields);
     $idFieldWithValue = self::_getMetaData('id');
     $table = self::_getMetaData('table');
     $preparedData = self::_getMetaData('data');
     $preparedFields = array_keys($preparedData);
     reset($idFieldWithValue);
     $_idField = key($idFieldWithValue);
     $_idValue = current($idFieldWithValue);
     $excludeIdField = false;
     if (!in_array($_idField, $preparedFields)) {
         $preparedFields[] = $_idField;
         $excludeIdField = true;
     }
     $condition = '1';
     if ($_idValue instanceof Zend_Db_Expr || $_idValue instanceof Zend_Db_Select) {
         $condition .= $this->_getWriteAdapter()->quoteInto(" AND {$_idField} ?", $_idValue);
     } elseif ($_idValue === false) {
         $condition .= " AND false";
     } elseif ($_idValue === null) {
         $condition .= $this->_getWriteAdapter()->quoteInto(" AND {$_idField} IS NULL", $_idValue);
     } elseif ($_idValue === true) {
     } else {
         $condition .= $this->_getWriteAdapter()->quoteInto(" AND {$_idField} in (?)", $_idValue);
     }
     $loadSel = $this->_getWriteAdapter()->select()->from($table, $preparedFields);
     $loadSel->where($condition);
     if (!empty($extraCondition)) {
         $extraCondition = str_replace('{{table}}', $table, $extraCondition);
         $loadSel->where($extraCondition);
     }
     if ($forUpdate) {
         $loadSel->forUpdate(true);
     }
     $result = array();
     $data = $this->_getWriteAdapter()->fetchAll($loadSel);
     if (is_array($data) && !empty($data)) {
         foreach ($data as $tmp) {
             $__idValue = $tmp[$_idField];
             $result[$__idValue] = $tmp;
             if ($excludeIdField) {
                 unset($result[$__idValue][$_idField]);
             }
         }
     }
     self::_transport(true);
     return $result;
 }
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:50,代码来源:Helper.php


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