lif*_*der 3 drupal foreign-keys drupal-7 drupal-modules drupal-schema
我在模块的Drupal 7架构上遇到了麻烦.有4个表,但样本2就足够了:
function mymodule_schema() {
$schema['series'] = array(
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => true,
'not null' => true,
),
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => true,
),
),
'unique keys' => array(
'name' => array('name'),
),
'primary key' => array('id'),
);
$schema['sermon'] = array(
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => true,
'not null' => true,
),
'title' => array(
'type' => 'varchar',
'length' => 255,
'not null' => true,
),
'series_id' => array(
'type' => 'int',
),
),
'foreign keys' => array(
'series_id' => array(
'table' => 'series',
'columns' => array('series_id' => 'id'),
),
),
'primary key' => array('id'),
);
return $schema;
}
Run Code Online (Sandbox Code Playgroud)
此代码创建表但不创建外键.我从Drupal.org获得的实现示例:http://drupal.org/node/146939
Drupal版本是7.0-beta 3.作为想法:也许,它还没有实现,我没有在node表中看到它(文档示例指向它的安装程序的代码).
谢谢您帮忙.