2

エンティティapiに依存するdrupal7.15でモジュールを作成しています。モジュール名はemployeeです。employee.installファイルとともにemployee.infoファイルを作成しました。しかし、データベースでは、employee.installファイルに自分で作成したデータベーススキーマが表示されません。これが私の.infoファイルと.installファイルをそれぞれ編集します。

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;
}
4

1 に答える 1

1

モジュールを最初にインストールした後、.installファイルにhook_schema()を追加しましたか?スキーマは、モジュールがインストールされている場合にのみインストールされます。(有効と混同しないでください)

モジュールを完全にアンインストールして、再インストールしてみてください。

1)モジュールを無効にします2)モジュールをアンインストールします(管理モジュールページのアンインストールタブから)3)モジュールを再インストールします

これにより、インストール時にhook_schemaがトリガーされます。フックの実装は問題ないようです。

スキーマに問題がある場合は、モジュールをインストールするときにエラーが表示されるはずです。(完全にアンインストールした後)エラーが画面に表示されるように設定されていない場合は、レポート->データベースログを確認してください。

files[] = employee.moduleまた、情報ファイルで宣言する必要はありません。

于 2013-02-25T23:49:45.823 に答える