【问题标题】:Module not accepting date type? Is there any other error that I am missing?模块不接受日期类型?还有其他我遗漏的错误吗?
【发布时间】:2013-06-19 15:43:33
【问题描述】:
<?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;
}

这段代码给了我以下错误: 注意:未定义索引:DatabaseSchema_mysql->processField() 中的 datetime:normal(C:\Documents and Settings\djeewani-si\Sites\acquia-drupal\includes\database\mysql\schema.inc 的第 205 行)。 PDOException: SQLSTATE[42000]: 语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 3 行的“NOT NULL COMMENT 'A field for storage an integer number”,mytextfield VARCHAR'附近使用正确的语法:CREATE TABLE {kronos} (fe_id INT unsigned NOT NULL auto_increment COMMENT '节点的主标识符。', Date NOT NULL COMMENT '用于存储整数的字段', mytextfield VARCHAR(50) NOT NULL DEFAULT '' COMMENT '用于存储短的字段文本字符串。', mytext TEXT NOT NULL COMMENT '用于存储较长文本的字段', PRIMARY KEY (fe_id) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT '示例表。'; db_create_table() 中的数组 ( )(C:\Documents and Settings\djeewani-si\Sites\acquia-drupal\includes\database\database.inc 的第 2717 行)。

【问题讨论】:

  • 任何帮助都会很棒。

标签: drupal-7 schema acquia


【解决方案1】:

从 D7 db api 中删除了日期时间支持 - 使用 mysql_type 或 pgsql_type 如果你想要这个功能。

试试这个:

'Date' => array(
  'description' => 'A field for storing date',
  'type' => 'datetime',
  'mysql_type' => 'datetime',
  'not null' => TRUE,
)

参考:https://drupal.org/node/159605

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-11
    • 2011-09-06
    • 1970-01-01
    • 1970-01-01
    • 2017-06-15
    • 2019-06-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多