문제

Hook_schema 함수를 사용하여 Drupal 데이터베이스에 테이블을 생성하려고 하는데 해결할 수 없는 PDO 예외 오류가 발생합니다.내 문제에 대한 해결책을 제공해 주시면 좋을 것 같습니다.

PDOException: 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 'DEFAULT '' COMMENT
'first name of the user', `lname` VARCHAR DEFAULT '' COMMENT' at line 3: 
CREATE TABLE {mage_user} ( `uid` INT unsigned NOT NULL auto_increment COMMENT 
'The foreign identifier for a mage user.', `fname` VARCHAR DEFAULT '' 
COMMENT 'first name of the user', `lname` VARCHAR DEFAULT '' COMMENT 
'last name of the user', `address1` VARCHAR(255) DEFAULT '' COMMENT 
'adress line 1', `address2` VARCHAR(255) DEFAULT '' COMMENT 'adress line 2',
`postcode` VARCHAR(7) DEFAULT '' COMMENT 'postcode', `gender` VARCHAR(6) 
DEFAULT ''  COMMENT 'gender' ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 
COMMENT 'The base table for mage user.'; Array ( ) in db_create_table() 
(line 2688 of E:\Server\drupal\includes\database\database.inc).

나는 사용하고있다

Apache/2.2.22 (Win32) PHP/5.3.10 MySQL 클라이언트 버전 :mysqlnd 5.0.8-dev - 20102224 - $Revision:321634 $

MySQL 서버 버전 5.5.21

내 스키마 정의는

    function mageacc_schema() {

          $schema['mageuser'] = array(
        'description' => 'The base table for mage user.', 
        'fields' => array(
        'uid' => array(
        'description' => 'The foreign identifier for a mage user.', 
        'type' => 'serial',  
        'not null' => TRUE,
  ), 
  'fname' => array(
    'description' => 'first name of the user', 
    'type' => 'varchar', 
    'lenght' => 255, 
    'default' => '',
  ),
      'lname' => array(
      'description' => 'last name of the user', 
      'type' => 'varchar', 
      'lenght' => 255, 
      'default' => '',
  ),
     'address1' => array(
     'description' => 'adress line 1', 
     'type' => 'varchar', 
     'length' => 255,
     'default' => '',

  ),
  'address2' => array(
      'description' => 'adress line 2', 
      'type' => 'varchar', 
      'length' => 255, 
      'default' => '',

     ),
     'postcode' => array(
      'description' => 'postcode', 
      'type' => 'varchar', 
      'length' => 7,  
       'default' => '',
    ),
    'gender'=>array(
    'description' => 'gender',
    'type' => 'varchar',
    'length' => 6,
    'default' => '',
    ),

  ), 

        );

  return $schema; 

}

미리 감사드립니다

도움이 되었습니까?

해결책

'length' 속성에서 몇 가지 오타를 발견했습니다.먼저 문제를 해결해 보세요. f이름 그리고 이름 작동하는지 확인하기 위해.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top