0

スキーマ モジュールと作成したテーブルの使用に問題があります。スキーマを使用してスキーマを作成した後、モジュール logo_management をインストールしようとすると、次のエラーが発生します。

Invalid default    value for 'logoid': 

CREATE TABLE {logo} ( `logoid` INT unsigned NULL auto_increment DEFAULT     
0 COMMENT 'Unique Logo ID', `date_created` NULL DEFAULT 0 COMMENT 
'The date the logo was    added.', `category` VARCHAR(50) NULL DEFAULT 
'OTHER' COMMENT 'The category the logo should be in.', `no_of_lines` 
INT NULL DEFAULT 1 COMMENT 'Number of lines(1 or 2)', 
`line_1` VARCHAR(100) NULL DEFAULT NULL COMMENT 'Line 1 for Logo', 
`line_2` VARCHAR(100) NULL DEFAULT NULL COMMENT 'Line 2 for Logo', 
`image_path` VARCHAR(100) NULL DEFAULT NULL COMMENT 
'Path and filename for image', `activate` 
 INT NULL DEFAULT 0 COMMENT 'Boolean if the logo should be active or not.', 
PRIMARY KEY (`logoid`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 

これが私が持っている .install スキーマです。「logoid」の無効なデフォルト値に何か問題があると思いますが、デフォルト値を入れてみましたが、それでも同じエラーが発生します。

function logo_management_schema() {
    $schema['logo'] = array(
      'description' => 'Logo Management Module',
       'fields' => array(
        'logoid' => array(
        'description' => 'Unique Logo ID',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
        'date_created' => array(
        'description' => 'The date the logo was added.',
        'type' => 'date',
        'not null' => TRUE,
    ),
    'category' => array(
      'description' => 'The category the logo should be in.',
      'type' => 'varchar',
      'length' => '50',
      'not null' => TRUE,
      'default' => 'OTHER',
    ), 
    'no_of_lines' => array(
      'description' => 'Number of lines(1 or 2)',
      'type' => 'int',
      'not null' => TRUE,
      'default' => 1,
    ),
    'line_1' => array(
      'description' => 'Line 1 for Logo',
      'type' => 'varchar',
      'length' => '100',
      'not null' => TRUE,
    ),
    'line_2' => array(
      'description' => 'Line 2 for Logo',
      'type' => 'varchar',
      'length' => '100',
      'not null' => FALSE,
    ),
    'image_path' => array(
      'description' => 'Path and filename for image',
      'type' => 'varchar',
      'length' => '100',
      'not null' => TRUE,
    ),
    'activate' => array(
      'description' => 'Boolean if the logo should be active or not.',
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
    ),
  ),
  'primary key' => array('logoid'),
);

return $schema;
}
4

1 に答える 1

0

スキルと決意がこの問題を解決しました! 型を int に変更しました。

$schema['logo'] = array(
      'description' => 'Logo Management Module',
      'fields' => array(
        'logoid' => array(
          'description' => 'Unique Logo ID',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
        )

次に、日付の問題に遭遇し、次のように変更しました。

    'date_created' => array(
      'description' => 'The date the logo was added.',
      'type' => 'datetime',
      'mysql_type' => 'DATETIME',
      'not null' => TRUE,
    ),

これでモジュールがインストールされます!

于 2013-06-07T22:42:52.587 に答える