我在模块文件中需要的具体内容是什么?
安装文件
function module_install(){
//lets create the school database
$create_table_sql = "CREATE TABLE IF NOT EXISTS `table1` (
id
int(11)NOT NULL,
principal_name
varchar(300)NOT NULL,
school_name
varchar(300)NOT NULL,
address1
varchar(300)NOT NULL,
address2
varchar(300)NOT NULL,
city
varchar(300)NOT NULL,
computer_serial_no
varchar(300)NOT NULL,
state
varchar(200)NOT NULL,
uid
int(200)NOT NULL
)ENGINE = InnoDB DEFAULT CHARSET = latin1“;
db_query($create_table_sql);
//lets create the student database
$ create_table_sql =“CREATE TABLE IF NOT NOT EXISTS table2
(
id
int(11)NOT NULL,
principal_name
varchar(300)NOT NULL,
school_name
varchar(300)NOT NULL,
address1
varchar(300)NOT NULL,
address2
varchar(300)NOT NULL,
city
varchar(300)NOT NULL,
computer_serial_no
varchar(300)NOT NULL,
state
varchar(200)NOT NULL,
uid
int(200)NOT NULL
)ENGINE = InnoDB DEFAULT CHARSET = latin1“;
db_query($create_table_sql);
}
/ ** * _UNINSTALL钩子 * *运行此功能以卸载模块。 * * / function module_uninstall(){
// Delete the DB
db_query("drop table table1");
db_query("drop table table2");
}
信息文件以防万一
; $Id$
name =我的模块 description =这个模块处理等等等等 package = Somepackage core = 6.x
version =“6.x-1.0” core =“6.x”
答案 0 :(得分:4)
您应该使用hook_install和hook_schema。
http://api.drupal.org/api/function/hook_schema/6
http://api.drupal.org/api/function/hook_install/6
对于安装和卸载,hook_schema将使其更加一致且更容易调试,而无需编写SQL。
答案 1 :(得分:1)
您无需编写自己的DDL查询 - 请改用Schema API。