Drupal 7 Drupal 7 hook_架构未安装数据库表
任何帮助都会很好Drupal 7 Drupal 7 hook_架构未安装数据库表,drupal-7,drupal-hooks,drupal-schema,Drupal 7,Drupal Hooks,Drupal Schema,任何帮助都会很好 function request_gold_pack_schema() { $schema['request_gold_pack_customer_details'] = array( 'description' => 'Table to store all customer details.', 'fields' => array( 'rid' => array(
function request_gold_pack_schema() {
$schema['request_gold_pack_customer_details'] = array(
'description' => 'Table to store all customer details.',
'fields' => array(
'rid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'auto increment' => TRUE
),
'title' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => ''
),
'first_name' => array(
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => ''
),
'last_name' => array(
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => ''
),
'house_name_no' => array(
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => ''
),
'street' => array(
'type' => 'varchar',
'length' => 160,
'not null' => TRUE,
'default' => ''
),
'town' => array(
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => ''
),
'county' => array(
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => ''
),
'telephone' => array(
'type' => 'int',
'length' => 12,
'not null' => TRUE,
'default' => ''
),
'email' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''
),
'date_registered' => array(
'mysql_type' => 'DATETIME',
'not null' => TRUE
),
'primary' => array(
'rid'
)
)
);
return $schema;
}
这给了我以下的错误
注意:未定义索引:键入DatabaseSchema_mysql->processField()(第205行/Users/richardskinner/Sites/www.goldrushmoney.com local/httpdocs/includes/database/mysql/schema.inc)。
注意:DatabaseSchema_mysql->processField()中的未定义索引::normal(第205行/Users/richardskinner/Sites/www.goldrushmoney.com local/httpdocs/includes/database/mysql/schema.inc)。
PDOException:SQLSTATE[42000]:语法错误或访问冲突:1064您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解使用第13行附近的'DEFAULT NULL)ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COMMENT'Table to stor':创建表{request_gold_pack_customer_details}(rid
INT NOT NULL DEFAULT 0,title
VARCHAR(10)非空默认“”,first\u name
VARCHAR(50)非空默认“”,last\u name
VARCHAR(50)非空默认“”,house\u name\u no
VARCHAR(50)非空默认“”,street
VARCHAR(160)非空默认“”,town
VARCHAR(50)非空默认“”,country
VARCHAR(50)非空默认值“”,telephone
INT非空默认值“”,email
VARCHAR(255)非空默认值“”,date\u registered
DATETIME非空,primary
DEFAULT NULL)ENGINE=InnoDB默认字符集utf8注释“存储所有客户详细信息的表”;db_create_table()中的数组()(第2688行/Users/richardskinner/Sites/www.goldrushmoney.com local/httpdocs/includes/database/database.inc)
几个小时来一直在寻找解决办法
谢谢。这是您的主键的问题。您在字段数组中列出了它(不应该是),它应该被引用为“主键”,而不是“主键”,如下所示:
function request_gold_pack_schema(){
$schema['request_gold_pack_customer_details'] = array(
'description' => 'Table to store all customer details.',
'fields' => array(
// Your field definitions
),
'primary key' => array(
'rid'
)
);
return $schema;
}
在drupal.org上查看
我还建议将rid
字段设置为typeserial
,并取消自动递增参数(Drupal将处理该问题)。因此,“rid”字段定义如下:
'rid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
)
您必须在drupal 7中为类型“int”指定大小…即
'rid' => array(
'type' => 'int',
'not null' => TRUE,
'size' => 'normal',
'auto increment' => TRUE,
),
大小可以是正常的,小的,大的
检查drupal 7数据类型。实际上,在您给出的链接中的{node}示例中,主键是“字段”下列出的第一个。这与我目前正在处理的示例模块中的entity_示例是一样的。也许这只是主要/主要的关键问题?我可能错了——我还没有开始工作。