您的位置:首页 > 数据库

drupal 创建数据库

2013-02-04 16:09 183 查看
1,在安装模块里面创建文件
   例如:模块名称为 myblog

  myblog.install

2,在文件中添加如下代码

<?php
function myblog_schema() {
$schema['myblog_project'] = array(
'description' => 'Update information for project translations.',
'fields' => array(
'name' => array(
'description' => 'A unique short name to identify the project.',
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'project_type' => array(
'description' => 'Project type, may be core, module, theme',
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'core' => array(
'description' => 'Core compatibility string for this project.',
'type' => 'varchar',
'length' => '128',
'not null' => TRUE,
'default' => '',
),
'version' => array(
'description' => 'Human readable name for project used on the interface.',
'type' => 'varchar',
'length' => '128',
'not null' => TRUE,
'default' => '',
),
'l10n_server' => array(
'description' => 'Localization server for this project.',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
),
'l10n_path' => array(
'description' => 'Server path this project updates.',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
),
'status' => array(
'description' => 'Status flag. TBD',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
),
'primary key' => array('name'),
);

$schema['myblog_file'] = array(
'description' => 'File and download information for project translations.',
'fields' => array(
'project' => array(
'description' => 'A unique short name to identify the project.',
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'language' => array(
'description' => 'Reference to the {languages}.language for this translation.',
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
),
'type' => array(
'description' => 'File origin: download or localfile',
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
'default' => '',
),
'filename' => array(
'description' => 'Link to translation file for download.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'fileurl' => array(
'description' => 'Link to translation file for download.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'uri' => array(
'description' => 'File system path for importing the file.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'timestamp' => array(
'description' => 'Unix timestamp of the time the file was downloaded or saved to disk. Zero if not yet downloaded',
'type' => 'int',
'not null' => FALSE,
'disp-width' => '11',
'default' => 0,
),
'version' => array(
'description' => 'Version tag of the downloaded file.',
'type' => 'varchar',
'length' => '128',
'not null' => TRUE,
'default' => '',
),
'status' => array(
'description' => 'Status flag. TBD',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'last_checked' => array(
'description' => 'Unix timestamp of the last time this translation was downloaded from or checked at remote server and confirmed to be the most recent release available.',
'type' => 'int',
'not null' => FALSE,
'disp-width' => '11',
'default' => 0,
),
),
'primary key' => array('project', 'language'),
);

$schema['cache_myblog'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_myblog']['description'] = 'Cache table for the Localization Update module to store information about available releases, fetched from central server.';

return $schema;
}
?>


    

    
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: