Datetime type in Drupal 7 schema(Drupal 7 模式中的日期时间类型)
问题描述
I'm writing a new Drupal 7 module (Drupal 7.10, Date 7.x-2.0-rc1 installed, Schema 7.x-1.0-beta3 installed) i defined a table in mymodule.install:
$schema['museums_tickets']= array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'day' => array(
'type' => 'datetime',
'mysql_type' => 'DATETIME',
'not null' => TRUE,
),
'tickets' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'ticket_code' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('nid', 'day','ticket_code'),
);
but i obtain the following errors:
Field museums_tickets.day: no Schema type for mysql type datetime.
museums_tickets.day: no type for Schema type datetime.
Field museums_tickets.day: no Schema type for type datetime.
The same applies if i use
'type' => 'datetime:normal',
I would like to know how to solve this problem. I don't want to store dates as timestamp, since another person wrote a lot of code and obviously i don't want to rewrite all. I already looked at drupal 7 custom schema error datetime but the answer doesn't work. Maybe i'm doing something wrong, but i don't find what.
Thank you in advance.
If you look in the schema of the Date module you will find something like
'day' => array(
'type' => 'datetime',
'mysql_type' => 'datetime',
)
Actually the answer of Clive was the one i picked first but later gave me problems with the Views module.
This implementation of the Date module save my day
这篇关于Drupal 7 模式中的日期时间类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Drupal 7 模式中的日期时间类型
基础教程推荐
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01