<?php
function kronos_schema() {
$schema=array();
$schema['kronos'] = array(
'description' => 'An example table.',
'fields' => array(
'fe_id' => array(
'description' => 'The primary identifier for a node.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'Date' => array(
'description' => 'A field for storing date',
'type' => 'datetime',
'not null' => TRUE,
),
'mytextfield' => array(
'description' => 'A field for storing short strings of text.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => '',
),
'mytext' => array(
'description' => 'A field for storing longer text',
'type' => 'text',
'not null' => TRUE,
),
),
'primary key' => array('fe_id'),
);
return $schema;
}
此代码给出了以下错误:
注意:未定义的索引:datetime:在DatabaseSchema_mysql中的正常 - > processField()(C:\ Documents and Settings \ djeewani-si \ Sites \ acquia-drupal \ includes \ database \ mysql \ schema.inc的第205行)。
PDOException:SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误;检查与MySQL服务器版本对应的手册,以便在“NOT NULL COMMENT”附近使用正确的语法。在第3行存储整数“mytextfield
VARCHAR”的字段:CREATE TABLE {kronos}({{ 1}} INT unsigned NOT NULL auto_increment COMMENT'节点的主要标识符。',fe_id
NOT NULL COMMENT'用于存储整数的字段',Date
VARCHAR(50)NOT NULL DEFAULT' 'COMMENT'用于存储短文本字符串的字段。',mytextfield
TEXT NOT NULL COMMENT'用于存储更长文本的字段',PRIMARY KEY(mytext
))ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT '一个示例表。'; db_create_table()中的Array()(C:\ Documents and Settings \ djeewani-si \ Sites \ acquia-drupal \ includes \ database \ database.inc的第2717行)。
答案 0 :(得分:2)
从D7 db api中删除了日期时间支持 - 使用mysql_type或 pgsql_type如果你想要这个功能。
试试这个:
'Date' => array(
'description' => 'A field for storing date',
'type' => 'datetime',
'mysql_type' => 'datetime',
'not null' => TRUE,
)