2016-10-02 108 views
0

在過去的幾個小時裏,我一直試圖在沒有運氣的自定義模塊中創建數據庫表!該文檔說你只需要在Drupal 7中實現hook_schema,並且Drupal在模塊安裝過程中負責創建表。我只是不知道爲什麼表沒有創建。我嘗試通過Drupal管理員安裝模塊以及粘貼模塊文件夾,但它仍然無法正常工作。使用Drupal創建數據庫表hook_schema()

這裏是我的.install文件中的功能:

/** 
* @return array an array containing table's field definitions 
* to be created by drupal schema api 
*/ 
function inquiry_form_schema() { 

    $schema['inquiry_form'] = array(
    'description' => 'Table to record inquiries submitted by staff', 
    'fields' => array(
     'ID' => array(
     'description' => 'The primary key of the table', 
     'type' => 'serial', 
     'size' => 'big', 
     'not null' => TRUE, 
    ), 
     'sender' => array(
     'description' => 'The person who submits the inquiry', 
     'type' => 'varchar', 
     'length' => '100', 
     'not null' => TRUE, 
    ), 
     'subject' => array(
     'description' => 'Title of the inquiry being submitted', 
     'type' => 'char', 
     'length' => '100', 
     'not null' => TRUE, 
    ), 
     'department' => array(
     'description' => 'The department that the inquiry is being referenced to', 
     'type' => 'varchar', 
     'length' => '100', 
     'not null' => TRUE, 
    ), 
     'description' => array(
     'description' => 'Detailed explanation of the issue the sender is experiencing', 
     'type' => 'text', 
     'not null' => TRUE, 
    ), 
//  'date' => array(
//  'description' => 'Date of the inquiry being submitted', 
//  'mysql_type' => 'datetime', 
//  'not null' => TRUE, 
//  ), 
    ), 
    'primary key' => array('ID'), 
); 

    return $schema; 
} 

回答

0

我假設你的文件是: - inquiry_form.info - inquiry_form.module - inquiry_form.install

是這個案件?

確保長度未被引用。 應該是100而不是'100'