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


PHP Mage_Core_Model_Resource_Setup::getConnection方法代码示例

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


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

示例1: testSetDeleteConfigData

 public function testSetDeleteConfigData()
 {
     $select = $this->_model->getConnection()->select()->from($this->_model->getTable('core_config_data'), 'value')->where('path=?', 'my/test/path');
     $this->_model->setConfigData('my/test/path', 'test_value');
     $this->assertEquals('test_value', $this->_model->getConnection()->fetchOne($select));
     $this->_model->deleteConfigData('my/test/path', 'test');
     $this->assertNotEmpty($this->_model->getConnection()->fetchRow($select));
     $this->_model->deleteConfigData('my/test/path');
     $this->assertEmpty($this->_model->getConnection()->fetchRow($select));
 }
开发者ID:natxetee,项目名称:magento2,代码行数:10,代码来源:SetupTest.php

示例2: setUp

 protected function setUp()
 {
     $installer = new Mage_Core_Model_Resource_Setup(Mage_Core_Model_Resource_Setup::DEFAULT_SETUP_CONNECTION);
     $this->_connection = $installer->getConnection();
     $this->_tableName = $installer->getTable('table_two_column_idx');
     $this->_oneColumnIdxName = $installer->getIdxName($this->_tableName, array('column1'));
     $this->_twoColumnIdxName = $installer->getIdxName($this->_tableName, array('column1', 'column2'));
     $table = $this->_connection->newTable($this->_tableName)->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), 'Id')->addColumn('column1', Varien_Db_Ddl_Table::TYPE_INTEGER)->addColumn('column2', Varien_Db_Ddl_Table::TYPE_INTEGER)->addIndex($this->_oneColumnIdxName, array('column1'))->addIndex($this->_twoColumnIdxName, array('column1', 'column2'));
     $this->_connection->createTable($table);
 }
开发者ID:nemphys,项目名称:magento2,代码行数:10,代码来源:InterfaceTest.php

示例3: replaceUniqueKey

 /**
  * Replace unique key
  * 
  * @param Mage_Core_Model_Resource_Setup $setup
  * @param string $tableName
  * @param string $keyName
  * @param array $keyAttributes
  * @return Innoexts_InnoCore_Helper_Database
  */
 public function replaceUniqueKey($setup, $tableName, $keyName, $keyAttributes)
 {
     $connection = $setup->getConnection();
     $versionHelper = $this->getVersionHelper();
     $table = $setup->getTable($tableName);
     if ($versionHelper->isGe1600()) {
         $indexTypeUnique = Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE;
         $indexes = $connection->getIndexList($table);
         foreach ($indexes as $index) {
             if ($index['INDEX_TYPE'] == $indexTypeUnique) {
                 $connection->dropIndex($table, $index['KEY_NAME']);
             }
         }
         $keyName = $setup->getIdxName($tableName, $keyAttributes, $indexTypeUnique);
         $connection->addIndex($table, $keyName, $keyAttributes, $indexTypeUnique);
     } else {
         $connection->addKey($table, $keyName, $keyAttributes, 'unique');
     }
     return $this;
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:29,代码来源:Database.php

示例4: saveAction

 public function saveAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
         $entityTypeId = $setup->getEntityTypeId('customer');
         $attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
         $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
         $attributeObject = Mage::getModel('customer/attribute');
         $attributeId = $this->getRequest()->getParam('id');
         $helper = Mage::helper('customerattribute');
         $attributeType = $attributeObject->load($attributeId)->getFrontendInput();
         if ($attributeId != null) {
             $data['frontend_input'] = $attributeType;
         }
         $data['validate_rules'] = $helper->getAttributeValidateRules1($data['frontend_input'], $data);
         if ($data['is_custom'] == 1 || $attributeId == 0) {
             if ($data['status'] == 1) {
                 if (in_array(1, $data['display_on_frontend'])) {
                     $data['used_in_forms'][] = 'customer_account_create';
                 }
                 if (in_array(2, $data['display_on_frontend'])) {
                     $data['used_in_forms'][] = 'customer_account_edit';
                 }
                 if ((in_array(3, $data['display_on_frontend']) || in_array(4, $data['display_on_frontend'])) && $attributeType != 'file' && $attributeType != 'image') {
                     $data['used_in_forms'][] = 'checkout_register';
                 }
                 if (in_array(1, $data['display_on_backend'])) {
                     $data['used_in_forms'][] = 'customer_Grid';
                 }
                 if (in_array(2, $data['display_on_backend'])) {
                     $data['used_in_forms'][] = 'order_grid';
                 }
                 if (in_array(3, $data['display_on_backend']) && $attributeType != 'file' && $attributeType != 'image') {
                     $data['used_in_forms'][] = 'adminhtml_checkout';
                 }
                 $data['used_in_forms'][] = 'tabCustomerattribute';
             } else {
                 $data['used_in_forms'][] = array();
             }
         }
         try {
             $data1 = array('status' => $data['status'], 'show_on_create_account' => (int) in_array(1, $data['display_on_frontend']), 'show_on_account_edit' => (int) in_array(2, $data['display_on_frontend']), 'show_on_checkout_register_customer' => (int) in_array(3, $data['display_on_frontend']), 'show_on_checkout_register_guest' => (int) in_array(4, $data['display_on_frontend']), 'show_on_grid_customer' => (int) in_array(1, $data['display_on_backend']), 'show_on_grid_order' => (int) in_array(2, $data['display_on_backend']), 'show_on_admin_checkout' => (int) in_array(3, $data['display_on_backend']), 'customer_group' => implode(", ", $data['customer_group']), 'store_id' => implode(", ", $data['store_view']));
             if ($attributeType == 'file' || $attributeType == 'image') {
                 $data1['show_on_checkout_register_customer'] = 0;
                 $data1['show_on_checkout_register_guest'] = 0;
                 $data1['show_on_admin_checkout'] = 0;
             }
             $model = Mage::getModel('customerattribute/customerattribute');
             if ($attributeId) {
                 $models = Mage::getModel('customerattribute/customerattribute')->getCollection()->addFieldToFilter('attribute_id', $attributeId)->getFirstItem();
                 $data1['attribute_id'] = $attributeId;
                 $attributeObject->load($attributeId)->addData($data);
                 $attributeObject->setId($attributeId)->save();
                 $model->load($models->getId())->setData($data1);
                 $model->setId($models->getId())->save();
                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customerattribute')->__('The customer attribute has been saved.'));
             } else {
                 $data['attribute_code'] = str_replace(' ', '', $data['attribute_code']);
                 $data['attribute_code'] = strtolower($data['attribute_code']);
                 $defaultValueField = $helper->getAttributeDefaultValueByInput($data['frontend_input']);
                 if ($defaultValueField) {
                     $scopeKeyPrefix = $this->getRequest()->getParam('website') ? 'scope_' : '';
                     $data[$scopeKeyPrefix . 'default_value'] = $helper->stripTags($this->getRequest()->getParam($scopeKeyPrefix . $defaultValueField));
                 }
                 $data['entity_type_id'] = $entityTypeId;
                 $data['attribute_group_id'] = $attributeGroupId;
                 $data['attribute_set_id'] = $attributeSetId;
                 $data['backend_type'] = $helper->getAttributeBackendTypeByInputType($data['frontend_input']);
                 $data['backend_model'] = $helper->getAttributeBackendModelByInputType($data['frontend_input']);
                 $data['source_model'] = $helper->getAttributeSourceModelByInputType($data['frontend_input']);
                 $data['is_system'] = 0;
                 $data['is_user_defined'] = 1;
                 if ($data['frontend_input'] == 'date') {
                     $data['input_filter'] = 'date';
                 }
                 $attributeObject->setData($data);
                 $attributeId = $attributeObject->save()->getId();
                 $data1['is_custom'] = 1;
                 $data1['attribute_id'] = $attributeId;
                 $model->setData($data1)->save();
                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customerattribute')->__('The customer customer attribute has been saved.'));
                 // Addcolumn to orderattribute table create by Hoatq
                 $table = new Mage_Core_Model_Resource_Setup();
                 $table->getConnection()->addColumn($table->getTable('orderattribute'), 'customer_' . $data['attribute_code'], 'varchar(255)');
             }
         } catch (Exception $e) {
             if (!$attributeId) {
                 $attributeCode = $data['attribute_code'];
                 $attributeObject = $this->_initAttribute()->loadByCode($this->_getEntityType()->getId(), $attributeCode);
                 if ($attributeObject->getId()) {
                     $this->_getSession()->addError(Mage::helper('customerattribute')->__('Attribute with the same code already exists'));
                 }
             } else {
                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customerattribute')->__('Unable to find item to save'));
             }
         }
         if ($this->getRequest()->getParam('back', false)) {
             $this->_redirect('*/*/edit', array('id' => $attributeId, '_current' => true));
             return;
         } else {
//.........这里部分代码省略.........
开发者ID:technomagegithub,项目名称:inmed-magento,代码行数:101,代码来源:CustomerattributeController.php

示例5: _setOrderIncrementPrefix

 /**
  * Set order number prefix
  *
  * @param Mage_Core_Model_Resource_Setup $setupModel
  * @param string $orderIncrementPrefix
  */
 protected function _setOrderIncrementPrefix(Mage_Core_Model_Resource_Setup $setupModel, $orderIncrementPrefix)
 {
     $select = $setupModel->getConnection()->select()->from($setupModel->getTable('eav_entity_type'), 'entity_type_id')->where('entity_type_code=?', 'order');
     $data = array('entity_type_id' => $setupModel->getConnection()->fetchOne($select), 'store_id' => '1', 'increment_prefix' => $orderIncrementPrefix);
     $setupModel->getConnection()->insert($setupModel->getTable('eav_entity_store'), $data);
 }
开发者ID:natxetee,项目名称:magento2,代码行数:12,代码来源:Installer.php

示例6:

<?php

$installer = new Mage_Core_Model_Resource_Setup();
$installer->getConnection()->addColumn($installer->getTable('newsletter_subscriber'), 'subscriber_firstname', 'varchar(50) AFTER subscriber_confirm_code');
$installer->getConnection()->addColumn($installer->getTable('newsletter_subscriber'), 'subscriber_lastname', 'varchar(50) AFTER subscriber_firstname');
开发者ID:santhosh400,项目名称:ecart,代码行数:5,代码来源:install-1.2.1.php

示例7: catch

    $_productsCollection->delete();
} catch (Exception $_e) {
    Mage::logException($_e);
}
/**************/

/** Drop tables */
$_tablesArray = array(
    'payperrentals' => array('excludeddates', 'mailinglog', 'ordertodates', 'rentalqueue', 'reservationorders', 'reservationprices', 'reservationquotes', 'sendreturn', 'serialnumbers', 'serialnumbersdetails'),
    'rshipping' => array('products', 'rshipping')
);
$_setupModel = new Mage_Core_Model_Resource_Setup('core_setup');
foreach ($_tablesArray as $_modelPrefix => $_tableArray) {
    foreach ($_tableArray as $_table) {
        try {
            $_setupModel->getConnection()->dropTable($_setupModel->getTable($_modelPrefix . '/' . $_table));
        } catch (Exception $_e) {
            Mage::logException($_e);
        }
    }
}
/**************/
/** Drop added columns */
$_columnsArray = array(
    'sales/quote' => array(
        'start_datetime',
        'end_datetime',
        'return_datetime',
        'send_datetime',
        'estimate_send',
        'estimate_return',
开发者ID:hueyl77,项目名称:fourwindsgear,代码行数:31,代码来源:rental-uninstall.php


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