1. <legend id='kjtVd'><style id='kjtVd'><dir id='kjtVd'><q id='kjtVd'></q></dir></style></legend>
  2. <i id='kjtVd'><tr id='kjtVd'><dt id='kjtVd'><q id='kjtVd'><span id='kjtVd'><b id='kjtVd'><form id='kjtVd'><ins id='kjtVd'></ins><ul id='kjtVd'></ul><sub id='kjtVd'></sub></form><legend id='kjtVd'></legend><bdo id='kjtVd'><pre id='kjtVd'><center id='kjtVd'></center></pre></bdo></b><th id='kjtVd'></th></span></q></dt></tr></i><div id='kjtVd'><tfoot id='kjtVd'></tfoot><dl id='kjtVd'><fieldset id='kjtVd'></fieldset></dl></div>
  3. <small id='kjtVd'></small><noframes id='kjtVd'>

    <tfoot id='kjtVd'></tfoot>

        <bdo id='kjtVd'></bdo><ul id='kjtVd'></ul>

      drupal 7 自定义架构错误日期时间

      时间:2023-06-22
        <legend id='jcOxm'><style id='jcOxm'><dir id='jcOxm'><q id='jcOxm'></q></dir></style></legend>

          • <tfoot id='jcOxm'></tfoot>
            <i id='jcOxm'><tr id='jcOxm'><dt id='jcOxm'><q id='jcOxm'><span id='jcOxm'><b id='jcOxm'><form id='jcOxm'><ins id='jcOxm'></ins><ul id='jcOxm'></ul><sub id='jcOxm'></sub></form><legend id='jcOxm'></legend><bdo id='jcOxm'><pre id='jcOxm'><center id='jcOxm'></center></pre></bdo></b><th id='jcOxm'></th></span></q></dt></tr></i><div id='jcOxm'><tfoot id='jcOxm'></tfoot><dl id='jcOxm'><fieldset id='jcOxm'></fieldset></dl></div>
              • <bdo id='jcOxm'></bdo><ul id='jcOxm'></ul>
                  <tbody id='jcOxm'></tbody>

                <small id='jcOxm'></small><noframes id='jcOxm'>

              • 本文介绍了drupal 7 自定义架构错误日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有以下架构(从带有 schema 模块 (7.x-1.0-beta3) 在自定义模块中.

                I have the following schema (generated from an existing table with the schema module (7.x-1.0-beta3) in a custom module.

                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,
                        ),
                        'day' => array(
                            'description' => 'Numbered day of campaign schedule',
                            'type' => 'int',
                            'not null' => TRUE,
                        ),
                        'content' => array(
                            'description' => 'Message content',
                            'type' => 'text',
                            'not null' => TRUE,
                        ),
                        'time_to_send' => array(
                            'description' => 'When the message should arrive at the user',
                            'type' => 'datetime',
                            'not null' => TRUE,
                        ),
                        'campaign_fk' => array(
                            'description' => 'the foreign key of the campaign this message belongs to',
                            'type' => 'int',
                            'unsigned' => TRUE,
                            'not null' => FALSE,
                        ),
                        'user_id' => array(
                            'description' => 'The user id this message is generated for',
                            'type' => 'int',
                            'unsigned' => TRUE,
                            'not null' => TRUE,
                        ),
                        'pool_id' => array(
                            'description' => 'The pool node id this message was generated from',
                            'type' => 'int',
                            'unsigned' => TRUE,
                            'not null' => TRUE,
                        ),
                        'message_template_id' => array(
                            'description' => 'The node id of the message template this message was generated from',
                            'type' => 'int',
                            'unsigned' => TRUE,
                            'not null' => TRUE,
                        ),
                    ),
                    'primary key' => array('id'),
                    'indexes' => array(
                        'CAMPAIGN' => array('campaign_fk'),
                        'MESSAGE_TEMPLATE' => array('message_template_id'),
                        'POOL' => array('pool_id'),
                        'USER' => array('user_id'),
                    ),
                );
                
                // ---------------------------------------------------------------------------------
                // CAMPAIGN
                // ---------------------------------------------------------------------------------
                $schema['myproject_entity_campaign'] = array(
                    'description' => 'The base table for myproject campaigns instances',
                    'fields' => array(
                        'id' => array(
                            'description' => 'The primary identifier for a campaign instance',
                            'type' => 'serial',
                            'unsigned' => TRUE,
                            'not null' => TRUE,
                        ),
                        'schedule' => array(
                            'description' => 'The schedule of the campaign in text format.',
                            'type' => 'text',
                            'not null' => TRUE,
                        ),
                        'interruptible' => array(
                            'description' => 'Whether this campaign is interruptible or not',
                            'type' => 'int',
                            'size' => 'tiny',
                            'not null' => TRUE,
                        ),
                        'campaign_template_id' => array(
                            'description' => 'Node id of campaign template this instance was created from',
                            'type' => 'int',
                            'unsigned' => TRUE,
                            'not null' => TRUE,
                        ),
                        'product_fk' => array(
                            'description' => 'Primary key of product instance this campaign belongs to',
                            'type' => 'int',
                            'unsigned' => TRUE,
                            'not null' => FALSE,
                        ),
                    ),
                    'primary key' => array('id'),
                    'indexes' => array(
                        'CAMPAIGN_TEMPLATE' => array('campaign_template_id'),
                        'PRODUCT' => array('product_fk'),
                    ),
                );
                
                // ---------------------------------------------------------------------------------
                // PRODUCT
                // ---------------------------------------------------------------------------------
                $schema['myproject_entity_product'] = array(
                    'description' => 'The base table for myproject product instances',
                    'fields' => array(
                        'id' => array(
                            'description' => 'The primary identifier for a product instance',
                            'type' => 'serial',
                            'unsigned' => TRUE,
                            'not null' => TRUE,
                        ),
                        'start' => array(
                            'description' => 'Time when the campaign started',
                            'type' => 'datetime',
                            'not null' => TRUE,
                        ),
                        'current_campaign_fk' => array(
                            'description' => 'Foreign key of currently running campaign instance',
                            'type' => 'int',
                            'unsigned' => TRUE,
                            'not null' => FALSE,
                        ),
                        'next_campaign_fk' => array(
                            'description' => 'Foreign key of campaign instance to run next',
                            'type' => 'int',
                            'unsigned' => TRUE,
                            'not null' => FALSE,
                        ),
                    ),
                    'primary key' => array('id'),
                    'indexes' => array(
                        'CURRENT' => array('current_campaign_fk'),
                        'NEXT' => array('next_campaign_fk'),
                    ),
                );
                
                return $schema;
                }
                

                当我尝试安装模块并因此创建架构时,我总是收到以下通知(我认为这不是失败的主要原因):

                When i try to install the module and thus create the schema, I always get the following notice (which I dont think is the main reason for failing):

                Notice: Undefined index: datetime:normal in DatabaseSchema_mysql->processField() (line 200 of /Users/xxx/Repos/myproject/includes/database/mysql/schema.inc).
                

                还有以下错误:

                PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL COMMENT 'When the message should arrive at the user', `campaign_fk` IN' at line 6: CREATE TABLE {myproject_entity_message} ( `id` INT unsigned NOT NULL auto_increment COMMENT 'The primary identifier for a message instance', `weekendday` TINYINT NOT NULL DEFAULT 0 COMMENT 'Whether this message gets send on a weekendday(1) or on a workday(0)', `day` INT NOT NULL COMMENT 'Numbered day of campaign schedule', `content` TEXT NOT NULL COMMENT 'Message content', `time_to_send` NOT NULL COMMENT 'When the message should arrive at the user', `campaign_fk` INT unsigned NULL DEFAULT NULL COMMENT 'the foreign key of the campaign this message belongs to', `user_id` INT unsigned NOT NULL COMMENT 'The user id this message is generated for', `pool_id` INT unsigned NOT NULL COMMENT 'The pool node id this message was generated from', `message_template_id` INT unsigned NOT NULL COMMENT 'The node id of the message template this message was generated from', PRIMARY KEY (`id`), INDEX `CAMPAIGN` (`campaign_fk`), INDEX `MESSAGE_TEMPLATE` (`message_template_id`), INDEX `POOL` (`pool_id`), INDEX `USER` (`user_id`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT 'The base table for myproject message instances'; Array ( ) in db_create_table() (line 2684 of /Users/xxx/Repos/myproject/includes/database/database.inc).
                

                我搜索了架构定义中的错误,但找不到任何错误.我也不明白 sql 语句到底有什么问题.

                I searched for errors in the schema definition but could not find any. Also I don't see what exactly is wrong with the sql statement.

                我的服务器设置是:Apache/2.2.20 (Unix) mod_ssl/2.2.20 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 with Suhosin-PatchMySQL 客户端版本:mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $

                My server setup is: Apache/2.2.20 (Unix) mod_ssl/2.2.20 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 with Suhosin-Patch MySQL client version: mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $

                有人看到这里有什么问题吗?

                Does anyone see whats wrong here?

                推荐答案

                认为你需要使用 datetime:normal 作为你的 datetime 列类型.

                I think you need to use datetime:normal as the key for your datetime column type.

                'time_to_send' => array(
                  'description' => 'When the message should arrive at the user',
                  'type' => 'datetime:normal',
                  'not null' => TRUE,
                ),
                

                除此之外,您可以尝试将列类型明确指定为 MySQL DATETIME:

                Other than that you can try specifying the column type as a MySQL DATETIME explicitly:

                'time_to_send' => array(
                  'description' => 'When the message should arrive at the user',
                  'mysql_type' => 'DATETIME',
                  'not null' => TRUE,
                ),
                

                问题似乎源于在 Drupal 7 中实际上是否允许 DATETIME;请参阅此讨论了解更多细节,我无法在这里介绍:)

                The problem seems to stem from whether or not DATETIME is actually allowed in Drupal 7; see this discussion for a lot more details than I can fit in here :)

                这篇关于drupal 7 自定义架构错误日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:将附件添加到 Jira 的 api 下一篇:Drupal 8:如何自定义表单小部件以显示实体字段值而不是实体标题?

                相关文章

              • <small id='0Vb14'></small><noframes id='0Vb14'>

                  • <bdo id='0Vb14'></bdo><ul id='0Vb14'></ul>

                    <tfoot id='0Vb14'></tfoot>
                    <i id='0Vb14'><tr id='0Vb14'><dt id='0Vb14'><q id='0Vb14'><span id='0Vb14'><b id='0Vb14'><form id='0Vb14'><ins id='0Vb14'></ins><ul id='0Vb14'></ul><sub id='0Vb14'></sub></form><legend id='0Vb14'></legend><bdo id='0Vb14'><pre id='0Vb14'><center id='0Vb14'></center></pre></bdo></b><th id='0Vb14'></th></span></q></dt></tr></i><div id='0Vb14'><tfoot id='0Vb14'></tfoot><dl id='0Vb14'><fieldset id='0Vb14'></fieldset></dl></div>
                  1. <legend id='0Vb14'><style id='0Vb14'><dir id='0Vb14'><q id='0Vb14'></q></dir></style></legend>