Magento 更改已有模組的資料庫表的字段資訊

2021-08-31 13:44:24 字數 774 閱讀 7362

比如要擴大模組對應的表的姓名一列的長度

1、首先增加指定模組的sql檔案,一般是模組名/sql/***_setup/upgrade_old_new.php old表示上一版本號,new代表本次版本號,new必須大於old,比如upgrade_1.0.0_1.1.0.php

2、編輯sql.php檔案

<?php 

/**$installer = $this;

$installer->startsetup();

$installer->getconnection()->modifycolumn( //modifycolumn代表修改列屬性

$installer->gettable('customer_user_need_check'), //模組對應的表名

'username',

array(

'type' => varien_db_ddl_table::type_text,

'length' => '500',

'nullable' => false,

'default' => "",

'comment' => 'image url'

));$installer->endsetup();

3、到模組名/etc/config.xml檔案中設定模組版本號,即new

4、重新整理快取即可

8 如何更改表內已有資訊,update的用法

假如,我們的students表中的sno有 s01 到 s07 這個時候,我們需要修改s01到s03的班級為20181121,s04到s07為20181181 那麼,輸入以下 update students set 班級 20181121 where sno s01 and sno s03 upda...

Oracle中在已有資料的表中更改字段型別(四步)

data型轉換成varchar型 第一步 alter table feesdetails info rename column prescription date to prescription date1 備註 把原欄位換個名字,此條的sql是把prescription date 換成prescr...

PS模組 更改系統 使用者狀態的函式

ps模組使用 kbps change status status change for activity 函式更改系統 使用者狀態。首先在kbps change status 函式內部,根據當前操作的tcode 標識不同的業務事務。控制的tcode 有 cj30 cj32 cj36 cj37 cj3...