在自定义一个字段模块时,为节点类型添加一个这个类型的字段实例时,报了以下错误信息:
Notice: Undefined index: integer:normal 在 DatabaseSchema_mysql->processField() (行 201 在 F:\xampp\htdocs\drupal\includes\database\mysql\schema.inc).
- 创建字段 t t t 遇到问题: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 DEFAULT 0, PRIMARY KEY (`entity_type`, `entity_id`, `deleted`, `delta`' at line 10 。
- 你的设置已被保存。
=== modified file 'shipping/uc_shipping/uc_shipping.install'
--- shipping/uc_shipping/uc_shipping.install 2010-03-03 15:47:24 +0000
+++ shipping/uc_shipping/uc_shipping.install 2010-03-08 14:35:33 +0000
@@ -251,7 +251,7 @@
'not null' => FALSE,
),
'label_image' => array(
- 'type' => 'integer',
+ 'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
@@ -303,7 +303,7 @@
$sandbox['#finished'] = 0;
$schema = array(
- 'type' => 'integer',
+ 'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
);
原来,我犯了同样的错误,将”int” 写成了“integer”,看来写程序,仅凭记忆还是不可靠的。下面是我定义的代码:
return array(
'columns' => array(
'value' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'sortable' => TRUE,
),
'manual' => array(
'type' => 'integer',
'not null' => TRUE,
'default' => 0,
),
),
);