drupal intsall module trouble
please verify my below code, my drupal is D6, Not creating table as well not deleting tables.
<?php
// custom1.install
function custom1_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE IF NOT EXISTS block_quiz_customer_ans (
crid int(30) NOT NULL AUTO_INCREMENT,
qid int(30) NOT NULL,
cust_ans varchar(255) NOT NULL,
cust_ip varchar(255) NOT NULL,
cust_res_date_time varchar(255) NOT NULL,
created varchar(50) NOT NULL,
status tinyint(20) NOT NULL DEFAULT '1',
PRIMARY开发者_Python百科 KEY (`crid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0;");
break;
}
}
function custom1_uninstall() {
print "This is uninstall";
drupal_uninstall_schema('block_quiz_customer_ans');
variable_del('block_quiz_customer_ans');
}
Use schema instead of mysql queries for the install file of a module.
function custom1_install(){
$schema['table_name'] = array(
'description' => '<description',
'fields' => array(
'field_name' => array(
'description' => '<description>',
'type' => '<datatype>',
),
),
'primary key' => array('<field_name>'),
);
return $schema;
}
Hope this helps!!
精彩评论