2012-11-30 1 views
1

도움이 될 것입니다. 불확정 지수 : 다음의 에러를 내게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; 
} 

> processField() /Users/richardskinner/Sites/www.goldrushmoney.com-local의 (라인 (205)을 입력 DatabaseSchema_mysql- /httpdocs/includes/database/mysql/schema.inc). 알림 : DatabaseSchema_mysql-> processField()의 정의되지 않은 인덱스 : : normal (/Users/richardskinner/Sites/www.goldrushmoney.com-local/httpdocs/includes/database/mysql/schema.inc의 205 행). PDOException : SQLSTATE [42000] : 구문 오류 또는 액세스 위반 : 1064 SQL 구문에 오류가 있습니다. 'DEFAULT NULL'근처에서 사용할 올바른 구문에 대해서는 MySQL 서버 버전에 해당하는 설명서를 확인하십시오. ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 13 행의 'Table to stor': 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 town VARCHAR (50) NOT NULL DEFAULT '', county VARCHAR (50) NOT NULL DEFAULT '', INT NOT NULL DEFAULT '', email VARCHAR (255) NOT NULL DEFAULT '', date_registered DATETIME NOT NULL, primary DEFAULT NULL) ENGINE = InnoDB 기본 문자 세트 utf8 COMMENT '모든 고객을 저장하는 테이블 r 세부 사항 '; db_create_table()의 Array() (/Users/richardskinner/Sites/www.goldrushmoney.com-local/httpdocs/includes/database/database.inc의 2688 행).

몇 시간 동안 해결책을 찾으려고했습니다.

감사합니다.

답변

2

기본 키에 문제가 있습니다. 당신은 필드의 배열에 나열된 HVE (는 안된다)과은과 같이, '기본 키'와 '주'하지로 참조해야합니다

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에 schema api documentation합니다.

rid 필드에 serial을 입력하고 자동 증가 매개 변수를 생략하는 것이 좋습니다 (Drupal이 처리 할 것입니다). 그래서 '제거'필드 정의와 같은 것 :

'rid' => array(
    'type' => 'serial', 
    'unsigned' => TRUE, 
    'not null' => TRUE, 
) 
+2

브릴리언트, 당신은 진정한 신사입니다. 완벽하게 일했습니다. 고맙습니다. –

+1

실제로, 제공된 링크의 {node} 예에서 기본 키는 '입력란'아래에 나열된 첫 번째 키입니다. 현재 작업중인 examples 모듈의 entity_example과 동일합니다. 아마도 그것은 기본/기본 키 문제일까요? 나는 틀릴 수도 있습니다 - 나는 아직 일하고 있습니다. –

0

당신은 유형 'INT'에 대한 드루팔 7의 크기를 지정해야합니다 ... 즉

'rid' => array(
'type' => 'int', 
'not null' => TRUE, 
'size' => 'normal', 
'auto increment' => TRUE, 
), 

크기가 정상이 될 수 있습니다, 작은, 큰 drupal 7 데이터 형식을 확인하십시오.