本文整理汇总了PHP中Mage_Core_Model_Resource_Setup::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Resource_Setup::getTable方法的具体用法?PHP Mage_Core_Model_Resource_Setup::getTable怎么用?PHP Mage_Core_Model_Resource_Setup::getTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Resource_Setup
的用法示例。
在下文中一共展示了Mage_Core_Model_Resource_Setup::getTable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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);
}
示例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;
}
示例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 {
//.........这里部分代码省略.........
示例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);
}
示例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');
示例7: reinstallAction
public function reinstallAction()
{
$installer = new Mage_Core_Model_Resource_Setup('core_setup');
$installer->startSetup();
$installer->run("\n\t\t\tDELETE FROM {$installer->getTable('core_resource')} WHERE `{$installer->getTable('core_resource')}`.`code` = 'webpos_setup';\n\t\t");
$installer->endSetup();
echo $this->__('Successfully! Please refresh magento cache to get the new version');
}
示例8: updatedb23Action
public function updatedb23Action()
{
$installer = new Mage_Core_Model_Resource_Setup();
$installer->startSetup();
$webposHelper = Mage::helper("webpos");
if (!$webposHelper->columnExist($installer->getTable('sales_flat_order'), 'webpos_admin_id')) {
$installer->run("ALTER TABLE {$installer->getTable('sales_flat_order')} ADD COLUMN `webpos_admin_id` int(10) default NULL");
}
if (!$webposHelper->columnExist($installer->getTable('sales_flat_order'), 'webpos_admin_name')) {
$installer->run("ALTER TABLE {$installer->getTable('sales_flat_order')} ADD COLUMN `webpos_admin_name` varchar(255) default NULL");
}
if (!$webposHelper->columnExist($installer->getTable('webpos_user'), 'store_ids')) {
$installer->run("ALTER TABLE {$installer->getTable('webpos_user')} ADD `store_ids` VARCHAR(255) NOT NULL AFTER `user_id`;");
}
if (!$webposHelper->columnExist($installer->getTable('webpos_transaction'), 'user_id')) {
$installer->run("ALTER TABLE {$installer->getTable('webpos_transaction')} ADD `user_id` int(4) unsigned DEFAULT NULL;");
}
if (!$webposHelper->columnExist($installer->getTable('webpos_transaction'), 'till_id')) {
$installer->run("ALTER TABLE {$installer->getTable('webpos_transaction')} ADD `till_id` unsigned NULL DEFAULT 0;");
}
if (!$webposHelper->columnExist($installer->getTable('webpos_transaction'), 'location_id')) {
$installer->run("ALTER TABLE {$installer->getTable('webpos_transaction')} ADD `location_id` unsigned NULL DEFAULT 0;");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'till_id')) {
$installer->run(" ALTER TABLE {$installer->getTable('sales/order')} ADD `till_id` int(11) unsigned NOT NULL DEFAULT 0; ");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'location_id')) {
$installer->run(" ALTER TABLE {$installer->getTable('sales/order')} ADD `location_id` int(11) unsigned NOT NULL DEFAULT 0; ");
}
if (!$webposHelper->columnExist($installer->getTable('sales/quote_payment'), 'ccforpos_ref_no')) {
$installer->run(" ALTER TABLE {$installer->getTable('sales/quote_payment')} ADD `ccforpos_ref_no` VARCHAR( 255 ) NOT NULL; ");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order_payment'), 'ccforpos_ref_no')) {
$installer->run(" ALTER TABLE {$installer->getTable('sales/order_payment')} ADD `ccforpos_ref_no` VARCHAR( 255 ) NOT NULL; ");
}
if (!$webposHelper->columnExist($installer->getTable('webpos_order'), 'till_id')) {
$installer->run(" ALTER TABLE {$installer->getTable('webpos_order')} ADD `till_id` int(11) unsigned NOT NULL DEFAULT 0; ");
}
if (!$webposHelper->columnExist($installer->getTable('webpos_order'), 'location_id')) {
$installer->run(" ALTER TABLE {$installer->getTable('webpos_order')} ADD `location_id` int(11) unsigned NOT NULL DEFAULT 0; ");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_cash')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_cash` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_base_cash')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_base_cash` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_cash')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_cash` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_base_cash')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_base_cash` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_ccforpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_ccforpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_base_ccforpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_base_ccforpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_ccforpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_ccforpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_base_ccforpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_base_ccforpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_cp1forpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_cp1forpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_base_cp1forpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_base_cp1forpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_cp1forpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_cp1forpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_base_cp1forpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_base_cp1forpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_cp2forpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_cp2forpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_base_cp2forpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_base_cp2forpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_cp2forpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_cp2forpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_base_cp2forpos')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_base_cp2forpos` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_change')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_change` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_base_change')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_base_change` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_change')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_change` decimal(12,4) NOT NULL default '0'");
}
if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_base_change')) {
$installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_base_change` decimal(12,4) NOT NULL default '0'");
//.........这里部分代码省略.........
示例9: foreach
'estimate_send',
'estimate_return',
'event_id',
'event_name',
'gate_name',
'damage_waiver_amount',
'base_damage_waiver_amount',
'damage_waiver_amount_invoiced',
'base_damage_waiver_amount_invoiced',
'damage_waiver_amount_refunded',
'base_damage_waiver_amount_refunded'
)
);
$_attributeModel = new Mage_Sales_Model_Resource_Setup('sales_setup');
foreach ($_attributesArray as $_attributeType => $_attributeArray) {
foreach ($_attributeArray as $_attributeCode) {
try {
$_attributeModel->removeAttribute($_attributeType, $_attributeCode);
} catch (Exception $_e) {
Mage::logException($_e);
}
}
}
/**************/
/** Remove resource data*/
$_setupModel = new Mage_Core_Model_Resource_Setup('core_setup');
$_setupModel->deleteTableRow($_setupModel->getTable('core/resource'), 'code', 'payperrentals_setup');
$_setupModel->deleteTableRow($_setupModel->getTable('core/resource'), 'code', 'rshipping_setup');
/**************/