2013-02-21 53 views
2

我在依賴於實體api的drupal 7.15中創建了一個模塊。 我的模塊名稱是員工 我已創建employee.info文件以及employee.install文件。 但在數據庫中,我無法在employee.install文件中看到自己創建的數據庫模式。 這是我的.info文件和.install文件分別編輯 :在自定義模塊創建中如何在drupal 7.15中查看基本數據庫表

name = Employee Management 
description = A module that describes about the employee management 
core = 7.x 
package = Employee management module 
files[] = employee.module 

編輯:

<?php 
/** 
* @file 
* Install for a employee entity - need to create the base table for our entity. 
* This table can have as many colums as you need to keep track of entity-specific 
* data that will not be added via attached fields. 
* The minimum information for the entity to work is an id and an entity name. 
*/ 

/** 
* Implements hook_schema() 
*/ 
function employee_schema() { 
$schema = array(); 

$schema['employee'] = array(
'description' => 'The base table for employee entity.', 
    'fields' => array(
    'employee_id' => array(
    'description' => 'Primary Key: Identifier for a employee entity.', 
    'type' => 'serial', 
    'unsigned' => TRUE, 
    'not null' => TRUE, 
    ), 
    'first_name' => array(
    'description' => 'The First name of employee entity.', 
    'type' => 'varchar', 
    'length' => 255, 
    'not null' => TRUE, 
    'default' => '', 
    ), 
    'last_name' => array(
    'description' => 'The Last name of employee entity.', 
    'type' => 'varchar', 
    'length' => 255, 
    'not null' => TRUE, 
    'default' => '', 
    ), 
    'employee_add' => array(
    'description' => 'The address of employee entity.', 
    'type' => 'varchar', 
    'length' => 255, 
    'not null' => TRUE, 
    'default' => '', 
    ), 
    'employee_doj' => array(
    'description' => 'The address of employee entity.', 
    'type' => 'date', 
    'not null' => TRUE, 
    'default' => '', 
    ), 
    ), 
    'primary key' => array('employee_id'), 
    ); 

return $schema; 
} 

回答

1

您最初安裝的模塊後,你加hook_schema()在.install文件?只有在模塊安裝後才能安裝模式。 (不要與啓用混淆)

嘗試完全卸載該模塊,然後重新安裝它:

1)禁止該模塊 2)卸載模塊(從卸載標籤管理員模塊頁) 3)重新安裝模塊

這應該在安裝時觸發hook_schema。你的鉤子實現看起來很好。

如果模式有問題,則在安裝模塊時應該會看到錯誤。 (完全卸載後)如果錯誤未設置爲在屏幕上顯示,請檢查報告 - >數據庫日誌。

另請注意,您不需要在您的信息文件中聲明files[] = employee.module

相關問題