本文整理汇总了PHP中Mage_Core_Model_Resource_Db_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Resource_Db_Abstract类的具体用法?PHP Mage_Core_Model_Resource_Db_Abstract怎么用?PHP Mage_Core_Model_Resource_Db_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Core_Model_Resource_Db_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
/**
* Perform actions before object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Db_Abstract
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (is_array($object->getChanges()) && sizeof($object->getChanges())) {
$object->setChanges(Zend_Json::encode($object->getChanges()));
}
return parent::_beforeSave($object);
}
示例2: _afterLoad
/**
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Db_Abstract
*/
protected function _afterLoad(Mage_Core_Model_Abstract $object)
{
if ($object->getData('additional')) {
$object->setData('additional', Mage::helper('core')->jsonDecode($object->getData('additional')));
}
return parent::_afterLoad($object);
}
示例3: _beforeSave
/**
* Perform actions before object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Db_Abstract
* @throws Mage_Core_Exception
*/
public function _beforeSave(Mage_Core_Model_Abstract $object)
{
if ($date = $object->getDateFrom()) {
$object->setDateFrom($this->formatDate($date));
} else {
$object->setDateFrom(null);
}
if ($date = $object->getDateTo()) {
$object->setDateTo($this->formatDate($date));
} else {
$object->setDateTo(null);
}
if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo()) && Varien_Date::toTimestamp($object->getDateFrom()) > Varien_Date::toTimestamp($object->getDateTo())) {
Mage::throwException(Mage::helper('core')->__('Start date cannot be greater than end date.'));
}
$check = $this->_checkIntersection($object->getStoreId(), $object->getDateFrom(), $object->getDateTo(), $object->getId());
if ($check) {
Mage::throwException(Mage::helper('core')->__('Your design change for the specified store intersects with another one, please specify another date range.'));
}
if ($object->getDateFrom() === null) {
$object->setDateFrom(new Zend_Db_Expr('null'));
}
if ($object->getDateTo() === null) {
$object->setDateTo(new Zend_Db_Expr('null'));
}
parent::_beforeSave($object);
}
示例4: _beforeSave
/**
* Add creation date to object
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Db_Abstract
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getAddedAt()) {
$object->setAddedAt($this->formatDate(true));
}
return parent::_beforeSave($object);
}
示例5: load
/**
* Load an object
*
* @param Mage_Core_Model_Abstract $object
* @param mixed $value
* @param string $field field to load by (defaults to model id)
* @return Mage_Core_Model_Resource_Db_Abstract
*/
public function load(Mage_Core_Model_Abstract $object, $value, $field = null)
{
if (!intval($value) && is_string($value)) {
$field = 'role_id';
}
return parent::load($object, $value, $field);
}
示例6: testGetTableName
/**
* @magentoConfigFixture global/resources/db/table_prefix prefix_
*/
public function testGetTableName()
{
$tableNameOrig = 'core_website';
$tableSuffix = 'suffix';
$tableName = $this->_model->getTable(array($tableNameOrig, $tableSuffix));
$this->assertEquals('prefix_core_website_suffix', $tableName);
}
示例7: testGetConnectionInMemoryCaching
/**
* Test that the model detects a connection when it becomes active
*/
public function testGetConnectionInMemoryCaching()
{
$connection = new Varien_Db_Adapter_Pdo_Mysql(array('dbname' => 'test_dbname', 'username' => 'test_username', 'password' => 'test_password'));
$this->_resource->expects($this->atLeastOnce())->method('getConnection')->with('core_read')->will($this->onConsecutiveCalls(false, $connection, false));
$this->assertFalse($this->_model->getReadConnection());
$this->assertSame($connection, $this->_model->getReadConnection(), 'Inactive connection should not be cached');
$this->assertSame($connection, $this->_model->getReadConnection(), 'Active connection should be cached');
}
示例8: load
/**
* Load an object using 'identifier' field
*
* @param Mage_Core_Model_Abstract $object
* @param mixed $value
* @param string $field
* @return Scandi_MenuManager_Model_Resource_Item
*/
public function load(Mage_Core_Model_Abstract $object, $value, $field = null)
{
if (!is_numeric($value) && is_null($field)) {
$field = 'identifier';
}
return parent::load($object, $value, $field);
}
示例9: _beforeSave
public function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$object->setCreatedate(now());
}
return parent::_beforeSave($object);
}
示例10: _afterSave
/**
* Perform actions after object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Eav_Model_Resource_Entity_Attribute_Set
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
if ($object->getGroups()) {
/* @var $group Mage_Eav_Model_Entity_Attribute_Group */
foreach ($object->getGroups() as $group) {
$group->setAttributeSetId($object->getId());
if ($group->itemExists() && !$group->getId()) {
continue;
}
$group->save();
}
}
if ($object->getRemoveGroups()) {
foreach ($object->getRemoveGroups() as $group) {
/* @var $group Mage_Eav_Model_Entity_Attribute_Group */
$group->delete();
}
Mage::getResourceModel('eav/entity_attribute_group')->updateDefaultGroup($object->getId());
}
if ($object->getRemoveAttributes()) {
foreach ($object->getRemoveAttributes() as $attribute) {
/* @var $attribute Mage_Eav_Model_Entity_Attribute */
$attribute->deleteEntity();
}
}
return parent::_afterSave($object);
}
示例11: _afterLoad
protected function _afterLoad(Mage_Core_Model_Abstract $object)
{
if ($object->getId()) {
$stores = $this->lookupStoreIds($object->getId());
$object->setData('store_id', $stores);
}
return parent::_afterLoad($object);
}
示例12: _prepareDataForSave
/**
* Prepare data for save
*
* @param Mage_Core_Model_Abstract $object
* @return array
*/
protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$object->setCreatedAt(now());
}
$data = parent::_prepareDataForSave($object);
return $data;
}
示例13: _getLoadSelect
/**
* Retrieve select object for load object data.
*
* @param string $field The field.
* @param mixed $value The value.
* @param Rootd_Link_Model_Node $object The link model.
*
* @return Zend_Db_Select
*/
protected function _getLoadSelect($field, $value, $object)
{
$select = parent::_getLoadSelect($field, $value, $object);
if (!is_null($object->getStoreId())) {
$select->where('store_id IN(?)', array(Mage_Core_Model_App::ADMIN_STORE_ID, $object->getStoreId()))->order('store_id ' . Varien_Db_Select::SQL_DESC)->limit(1);
}
return $select;
}
示例14: _getLoadSelect
/**
* Retrieve select object for load object data
*
* @param string $field
* @param mixed $value
* @param Mage_Core_Model_Abstract $object
*
* @return Zend_Db_Select
*/
protected function _getLoadSelect($field, $value, $object)
{
$select = parent::_getLoadSelect($field, $value, $object);
if ($object->getStoreId()) {
$select->join(array('cps' => $this->getTable('store')), $this->getMainTable() . '.slideshow_id = `cps`.slideshow_id')->where('`cps`.store_id in (0, ?) ', $object->getStoreId())->order('store_id DESC')->limit(1);
}
return $select;
}
示例15: _beforeSave
/**
* Before save
* @param Mage_Core_Model_Abstract $object
* @return AntoineK_Slider_Model_Resource_Slider
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$object->setCreatedAt(Mage::getSingleton('core/date')->gmtDate());
}
$object->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate());
return parent::_beforeSave($object);
}