久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Magento 安裝腳本中的 ALTER TABLE 不使用 SQL

ALTER TABLE in Magento setup script without using SQL(Magento 安裝腳本中的 ALTER TABLE 不使用 SQL)
本文介紹了Magento 安裝腳本中的 ALTER TABLE 不使用 SQL的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

喬納森日說

"更新不應(yīng)該是SQL 命令".我沒有遇到過任何 DDL 或 DML 語句不能通過 Magento 的配置執(zhí)行結(jié)構(gòu).

"updates SHOULD NOT be in the form of SQL commands". I haven't come across any DDL or DML statments that cannot be executed via Magento's config structures.

(在問題如何將配置更改從開發(fā)環(huán)境遷移到生產(chǎn)環(huán)境?)

我想知道如何最好地以這種方式在表中添加/修改/刪除列或索引,但又不依賴于 SQL?甚至有可能嗎?

I would like to know how best to add/modify/remove a column or index to/from a table in this manner, but without relying on SQL? Is it even possible?

此外,還有哪些操作只能在 SQL 中完成?

Furthermore, what other actions can only be done in SQL?

推薦答案

您可以在安裝腳本中使用此類方法:

You can use such methods within your setup script:

  • 使用Varien_Db_Ddl_Table 類創(chuàng)建新表,可以在其中配置所有字段、鍵、關(guān)系,結(jié)合$this->getConnection()->createTable($tableObject)示例:

  • Use Varien_Db_Ddl_Table class to create new tables, where you can configure all the fields, keys, relations in combination with $this->getConnection()->createTable($tableObject) Example:

/* @var $this Mage_Core_Model_Resource_Setup */
$table = new Varien_Db_Ddl_Table();
$table->setName($this->getTable('module/table'));
$table->addColumn('id', Varien_Db_Ddl_Table::TYPE_INT, 10, 
                  array('unsigned' => true, 'primary' => true));

$table->addColumn('name', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255);
$table->addIndex('name', 'name');
$table->setOption('type', 'InnoDB');
$table->setOption('charset', 'utf8');

$this->getConnection()->createTable($table);

  • 使用設(shè)置連接($this->getConnection())方法:

    • addColumn() 方法將新列添加到現(xiàn)有表中.它有這樣的參數(shù):
      • $tableName - 需要修改的表名
      • $columnName- 需要添加的列名
      • $definition - 列的定義(INT(10)DECIMAL(12,4) 等)
      • addColumn() method adds new column to exiting table. It has such parameters:
        • $tableName - the table name that should be modified
        • $columnName- the name of the column, that should be added
        • $definition - definition of the column (INT(10), DECIMAL(12,4), etc)
        • $fkName - 外鍵名稱,每個(gè)數(shù)據(jù)庫應(yīng)該是唯一的,如果你不指定FK_前綴,它會自動添加
        • $tableName - 添加外鍵的表名
        • $columnName - 應(yīng)該引用到另一個(gè)表的列名,如果你有復(fù)雜的外鍵,用逗號指定多列
        • $refTableName - 外表名,將被處理
        • $refColumnName - 外部表中的列名
        • $onDelete - 在外部表中刪除行的操作.可以是空字符串(什么都不做),cascadeset null.此字段是可選的,如果未指定,將使用 cascade 值.
        • $onUpdate 外部表中行鍵更新的操作.可以是空字符串(什么都不做),cascadeset null.此字段是可選的,如果未指定,將使用 cascade 值.
        • $purge - 在添加外鍵后啟用行清理的標(biāo)志(例如,刪除未引用的記錄)
        • $fkName - the foreign key name, should be unique per database, if you don't specify FK_ prefix, it will be added automatically
        • $tableName - the table name for adding a foreign key
        • $columnName - the column name that should be referred to another table, if you have complex foreign key, use comma to specify more than one column
        • $refTableName - the foreign table name, which will be handled
        • $refColumnName - the column name(s) in the foreign table
        • $onDelete - action on row removing in the foreign table. Can be empty string (do nothing), cascade, set null. This field is optional, and if it is not specified, cascade value will be used.
        • $onUpdate action on row key updating in the foreign table. Can be empty string (do nothing), cascade, set null. This field is optional, and if it is not specified, cascade value will be used.
        • $purge - a flag for enabling cleaning of the rows after foreign key adding (e.g. remove the records that are not referenced)
        • $tableName - 應(yīng)該添加索引的表名
        • $indexName - 索引名稱
        • $fields - 索引中使用的列名
        • $indexType - 索引的類型.可能的值有:index、unique、primaryfulltext.該參數(shù)是可選的,所以默認(rèn)值為index
        • $tableName - the table name where the index should be added
        • $indexName - the index name
        • $fields - column name(s) used in the index
        • $indexType - type of the index. Possible values are: index, unique, primary, fulltext. This parameter is optional, so the default value is index
        • $tableName - 需要修改的表名
        • $columnName- 應(yīng)該刪除的列的名稱
        • $tableName - the table name that should be modified
        • $columnName- the name of the column, that should removed
        • $tableName - 刪除外鍵的表名
        • $fkName - 外鍵名稱
        • $tableName - the table name for removing a foreign key
        • $fkName - the foreign key name
        • $tableName - 應(yīng)該刪除索引的表名
        • $keyName - 索引名稱
        • $tableName - the table name where the index should be removed
        • $keyName - the index name
        • $tableName - 需要修改的表名
        • $columnName- 應(yīng)該重命名的列的名稱
        • $definition - 列的新定義(INT(10)DECIMAL(12,4) 等)
        • $tableName - the table name that should be modified
        • $columnName- the name of the column, that should be renamed
        • $definition - a new definition of the column (INT(10), DECIMAL(12,4), etc)
        • $tableName - 需要修改的表名
        • $oldColumnName- 列的舊名稱,應(yīng)重命名和修改
        • $newColumnName- 列的新名稱
        • $definition - 列的新定義(INT(10)、DECIMAL(12,4) 等)
        • $tableName - the table name that should be modified
        • $oldColumnName- the old name of the column, that should be renamed and modified
        • $newColumnName- a new name of the column
        • $definition - a new definition of the column (INT(10), DECIMAL(12,4), etc)
        • $tableName - 表名
        • $engine - 新引擎名稱(MEMORY、MyISAM、InnoDB 等)
        • $tableName - the table name
        • $engine - new engine name (MEMORY, MyISAM, InnoDB, etc)

        您也可以使用 tableColumnExists 方法來檢查列是否存在.

        Also you can use tableColumnExists method to check existence of the column.

        這不是您可以使用的完整方法列表,以擺脫直接編寫 SQL 查詢.您可以在 Varien_Db_Adapter_Pdo_MysqlZend_Db_Adapter_Abstract 類中找到更多信息.

        It is not the full list of methods that are available for you, to get rid of direct SQL queries writing. You can find more at Varien_Db_Adapter_Pdo_Mysql and Zend_Db_Adapter_Abstract classes.

        不要猶豫,查看您將要使用的類定義,您可以為自己找到很多有趣的東西:)

        Do not hesitate to look into the class definition which you are going to use, you can find a lot of interesting things for yourself :)

        這篇關(guān)于Magento 安裝腳本中的 ALTER TABLE 不使用 SQL的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

        【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!
  • 相關(guān)文檔推薦

    Magento products by categories(按類別劃分的 Magento 產(chǎn)品)
    Resource interpreted as image but transferred with MIME type text/html - Magento(資源被解釋為圖像但使用 MIME 類型 text/html 傳輸 - Magento)
    Is there an event for customer account registration in Magento?(Magento 中是否有客戶帳戶注冊事件?)
    Magento addFieldToFilter: Two fields, match as OR, not AND(Magento addFieldToFilter:兩個(gè)字段,匹配為 OR,而不是 AND)
    quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到錯(cuò)誤 404在 Magento 管理員登錄頁面)
    Get Order Increment Id in Magento(在 Magento 中獲取訂單增量 ID)
    主站蜘蛛池模板: 久久久久久久久久久久久久国产 | 欧美天堂一区 | 噜啊噜在线 | aaa国产大片 | 91中文视频| 精品亚洲一区二区三区 | 久久综合国产精品 | 亚洲精品国产成人 | 日韩精品999 | 国产视频在线观看一区二区三区 | 国产欧美在线播放 | 国产亚洲精品一区二区三区 | 夜久久 | 日韩国产中文字幕 | 欧美一区二区三区久久精品 | 成人av在线播放 | 一区二区中文 | 国产精品18久久久久久久 | 欧美一卡二卡在线观看 | 亚洲一区 中文字幕 | 天天天堂 | 亚洲精品一区二区三区蜜桃久 | 国产xxxx搡xxxxx搡麻豆 | 国产精品高潮呻吟久久 | 国产乱肥老妇国产一区二 | 国产1区在线 | 午夜在线小视频 | 日韩免费高清视频 | 国产激情一区二区三区 | 夜夜爽99久久国产综合精品女不卡 | 欧美精 | 亚洲一区在线日韩在线深爱 | 国产美女永久免费无遮挡 | 天堂成人av| 韩日免费视频 | 人成精品 | 欧美一区二区小视频 | 中文字幕在线中文 | 国产精品一区二区久久久久 | 久久99精品久久久久久秒播九色 | 国产精品激情在线 |