Drupal 6模块安装文件不在数据库中创建表 [英] Drupal 6 module install file not creating tables in database
本文介绍了Drupal 6模块安装文件不在数据库中创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Schema API为Drupa 6.17上的模块创建表,但是表不会在数据库中创建。我已经安装了Schema模块,它告诉我,当我的模块的模式被识别时,它的表不在数据库中。它出现在Missing下:
I'm using the Schema API to create tables for my module on Drupa 6.17, but the tables just do not get created in the database. I have the Schema module installed, and it tells me that while the schema for my module is recognized, its table is not in the database. It comes up under Missing:
Tables in the schema that are not present in the database.
test
* test_table
这是我的test.install文件的内容。
Here are the contents for my test.install file.
<?php
// $Id$
function test_schema() {
$schema['test_table'] = array(
'description' => t('Test table'),
'fields' => array(
'nid' => array(
'description' => t('test field'),
'type' => 'serial',
'not null' => TRUE,
),
'options' => array(
'description' => t('other test field'),
'type' => 'text',
'not null' => FALSE,
),
),
'primary key' => array('nid'),
);
return $schema;
}
function test_install() {
drupal_install_schema('test');
}
function test_uninstall() {
drupal_uninstall_schema('test');
}
推荐答案
编辑:
这里是我刚写的代码。按照示例:
Here is code I just wrote that works. Follow as example:
/**
* Implementation of hook_schema().
*/
function action_alert_schema() {
$schema['action_alert'] = array(
'description' => 'Action Alert table.',
'fields' => array(
'aid' => array(
'description' => 'The serial ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'nid' => array(
'description' => 'The primary identifier of the node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'uuid' => array(
'description' => 'The session id of the user if the UID is not present.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '0',
),
),
'primary key' => array('aid'),
);
return $schema;
}
/**
* Implementation of hook_install().
*/
function action_alert_install() {
drupal_install_schema('action_alert');
}
/**
* Implementation of hook_uninstall().
*/
function action_alert_uninstall() {
drupal_uninstall_schema('action_alert');
}
这篇关于Drupal 6模块安装文件不在数据库中创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文