本文整理汇总了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'));
}
}
示例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);
}
示例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;
}
示例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());
}
}
示例5: getResource
/**
* Retrieve resource model wraper
*
* @return Mage_CatalogInventory_Model_Mysql4_Stock_Status
*/
public function getResource()
{
return parent::getResource();
}
示例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();
}
}
}
示例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;
}