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

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

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

問題描述

喬納森日說

"更新不應該是SQL 命令".我沒有遇到過任何 DDL 或 DML 語句不能通過 Magento 的配置執行結構.

"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.

(在問題如何將配置更改從開發環境遷移到生產環境?)

我想知道如何最好地以這種方式在表中添加/修改/刪除列或索引,但又不依賴于 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 類創建新表,可以在其中配置所有字段、鍵、關系,結合$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);

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

    • addColumn() 方法將新列添加到現有表中.它有這樣的參數:
      • $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 - 外鍵名稱,每個數據庫應該是唯一的,如果你不指定FK_前綴,它會自動添加
        • $tableName - 添加外鍵的表名
        • $columnName - 應該引用到另一個表的列名,如果你有復雜的外鍵,用逗號指定多列
        • $refTableName - 外表名,將被處理
        • $refColumnName - 外部表中的列名
        • $onDelete - 在外部表中刪除行的操作.可以是空字符串(什么都不做),cascadeset null.此字段是可選的,如果未指定,將使用 cascade 值.
        • $onUpdate 外部表中行鍵更新的操作.可以是空字符串(什么都不做),cascadeset null.此字段是可選的,如果未指定,將使用 cascade 值.
        • $purge - 在添加外鍵后啟用行清理的標志(例如,刪除未引用的記錄)
        • $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 - 應該添加索引的表名
        • $indexName - 索引名稱
        • $fields - 索引中使用的列名
        • $indexType - 索引的類型.可能的值有:indexuniqueprimaryfulltext.該參數是可選的,所以默認值為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- 應該刪除的列的名稱
        • $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 - 應該刪除索引的表名
        • $keyName - 索引名稱
        • $tableName - the table name where the index should be removed
        • $keyName - the index name
        • $tableName - 需要修改的表名
        • $columnName- 應該重命名的列的名稱
        • $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- 列的舊名稱,應重命名和修改
        • $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 - 新引擎名稱(MEMORYMyISAMInnoDB 等)
        • $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 :)

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

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

    Magento products by categories(按類別劃分的 Magento 產品)
    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:兩個字段,匹配為 OR,而不是 AND)
    quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到錯誤 404在 Magento 管理員登錄頁面)
    Get Order Increment Id in Magento(在 Magento 中獲取訂單增量 ID)
    主站蜘蛛池模板: 操操日| 欧美日韩视频在线 | 亚洲人在线观看视频 | 2021狠狠天天天 | 亚洲 欧美 日韩在线 | av一级 | 人妖一区| 在线成人免费视频 | 精品91久久 | 亚洲九色| 中文字幕一级 | 免费观看成人av | 中文字幕国产视频 | 美女福利视频一区 | 国产成人精品一区二区三区在线 | 在线视频一区二区三区 | 成人黄色三级毛片 | 亚洲视频免费在线观看 | 久久久国产视频 | 欧美亚洲日本 | 羞羞视频免费观看 | 91一区二区在线观看 | 亚洲欧美综合精品另类天天更新 | 亚洲精品日韩一区二区电影 | 自拍偷拍亚洲欧美 | 玩丰满女领导对白露脸hd | 少妇诱惑av | 国产一区二区三区视频在线观看 | 北条麻妃国产九九九精品小说 | 久热国产精品 | 久久91精品久久久久久9鸭 | 欧美视频在线观看 | 欧美一级片在线观看 | 91在线观看 | 久草高清视频 | 亚洲免费观看视频网站 | 99爱视频 | 久久精品一级 | 在线中文字幕第一页 | 久久精品国产清自在天天线 | 99久久婷婷国产综合精品电影 |