标签: drupal-schema

架构中有多个主键

我有这个架构,我需要定义两个主键; 一个是Drupal的'vid'字段,另一个是我的网站'bid'字段,它是自动增量类型,反过来要求它是主键:wtherwise我得到MySQL错误.我在查找Drupal模式中定义多个主键的语法时遇到了麻烦.如果有人可以帮我解决语法问题,我非常感谢.

$schema['rft'] = array(
    'fields' => array(
        'vid' => array(
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'default' => 0,
        ),
        'nid' => array(
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'default' => 0,
        ),
        'bid' => array(
            'type' => 'serial',
            'size' => 'medium',
            'not null' => TRUE,                         
        ),

    ),
    'indexes' => array(
        'nid' => array('nid'),
    ),
    'primary key' => array('vid'),  //array('vid','bid') doesn't work
);

return $schema;
}
Run Code Online (Sandbox Code Playgroud)

drupal primary-key drupal-schema

4
推荐指数
1
解决办法
3880
查看次数

drupal 7自定义架构错误datetime

我有以下架构(从自定义模块中的架构模块(7.x-1.0-beta3)的现有表生成.

function myproject_entities_schema() {

// ---------------------------------------------------------------------------------
// MESSAGE
// ---------------------------------------------------------------------------------
$schema['myproject_entity_message'] = array(
    'description' => 'The base table for myproject message instances',
    'fields' => array(
        'id' => array(
            'description' => 'The primary identifier for a message instance',
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE,
        ),
        'weekendday' => array(
            'description' => 'Whether this message gets send on a weekendday(1) or on a workday(0)',
            'type' => 'int',
            'size' => 'tiny',
            'not null' => TRUE,
            'default' => 0, …
Run Code Online (Sandbox Code Playgroud)

php mysql drupal drupal-7 drupal-schema

4
推荐指数
1
解决办法
4509
查看次数

Drupal 7架构中的外键问题

我在模块的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' …
Run Code Online (Sandbox Code Playgroud)

drupal foreign-keys drupal-7 drupal-modules drupal-schema

3
推荐指数
1
解决办法
3356
查看次数