ko tao duoc table trong file .install

Events happening in the community are now at Drupal community events on www.drupal.org.
ocditimban's picture

<?php
function insertTable_schema(){
$schema['example']=array(
'fields' => array(
'nid' => array('type' =>'int','not null' => TRUE,'unsigned' => TRUE,'default' =>0),
),
'primary key' => array('nid'),
);
return $schema;
}
function insertTable_install(){
db_insert('example')
->fields(array(
'nid' =>1,
))
->execute();

}
function insertTable_uninstall() {

variable_del('example_default_status');
variable_del('example_threshold_limit');
variable_del('example_threshold_window');
}
ai giup em voi

Comments

Tạo bình thường. Có thể

ChoNguyenVan's picture

Tạo bình thường.
Có thể module bạn đang viết bị bug ở đâu đó, bạn xóa hết đi chỉ để lại đoạn install này thôi xem sao.
Tham khảo module mình copy từ code của bạn http://chonguyenvan.com/wp-content/uploads/drupal/db_insert_table-7.x-1....
Install / uninstall nó create / drop table ngon lành.

tao duoc table trong file .install

inmyhometv's picture

Hay... Nhưng cũng được. :d
function insertTable_install(){
drupal_install_schema('example');
}
function insertTable_uninstall(){
drupal_uninstall_schema('example');
}
ok?