任何幫助都會很棒。Drupal 7 hook_schema沒有安裝數據庫表
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()(/Users/richardskinner/Sites/www.goldrushmoney.com-local的205線/httpdocs/includes/database/mysql/schema.inc)。 注意:在DatabaseSchema_mysql-> processField()(/Users/richardskinner/Sites/www.goldrushmoney.com-local/httpdocs/includes/database/mysql/schema.inc)的第205行中未定義索引::正常。 PDOException:SQLSTATE [42000]:語法錯誤或訪問衝突:1064您的SQL語法中有錯誤;檢查與您的MySQL服務器版本對應的手冊,以在DEFAULT NULL附近使用正確的語法ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT'Table to stor'at line 13:CREATE TABLE {request_gold_pack_customer_details}(
rid
INT NOT NULL DEFAULT 0 ,title
VARCHAR(10)NOT NULL DEFAULT'',first_name
VARCHAR(50)NOT NULL DEFAULT'',last_name
VARCHAR(50)NOT NULL DEFAULT'',house_name_no
VARCHAR(50)NOT NULL DEFAULT'',street
VARCHAR(160) NOT NULL DEFAULT'',town
VARCHAR(50)NOT NULL DEFAULT'',county
VARCHAR(50)NOT NULL DEFAULT'',telephone
INT NOT NULL DEFAULT'',date_registered
DATETIME NOT NULL,primary
DEFAULT NULL)ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT'Table to store all custome詳細信息。'; db_create_table()中的Array()(/Users/richardskinner/Sites/www.goldrushmoney.com-local/httpdocs/includes/database/database.inc的第2688行)。
一直試圖找到一個小時的解決方案。
謝謝。
輝煌,你是一個真正的紳士。完美地工作。謝謝。 –
實際上,在您給出的鏈接的{node}示例中,主鍵是'fields'下列出的第一個鍵。這與我目前正在處理的示例模塊中的entity_example一樣。也許這只是主要/主要問題?我可能是錯的 - 我還沒有得到我的工作。 –