2013-06-19 3 views
0
<?php 

function kronos_schema() { 
    $schema=array(); 
    $schema['kronos'] = array(

     'description' => 'An example table.', 
    'fields' => array(
     'fe_id' => array(
     'description' => 'The primary identifier for a node.', 
     'type' => 'serial', 
     'unsigned' => TRUE, 
     'not null' => TRUE, 
    ), 
     'Date' => array(
     'description' => 'A field for storing date', 
     'type' => 'datetime', 
     'not null' => TRUE, 
    ), 
     'mytextfield' => array(
     'description' => 'A field for storing short strings of text.', 
     'type' => 'varchar', 
     'length' => 50, 
     'not null' => TRUE, 
     'default' => '', 
    ), 
     'mytext' => array(
     'description' => 'A field for storing longer text', 
     'type' => 'text', 
     'not null' => TRUE, 
    ), 
    ), 
    'primary key' => array('fe_id'), 
); 
    return $schema; 
} 

이 코드는 나에게 다음과 같은 오류를 제공 정의되지 않은 인덱스 : 날짜 : DatabaseSchema_mysql- 정상을> processField() (C 라인 (205) : \ 문서 및 설정 \ djeewani 실리콘 \ 사이트 \ Acquia의-드루팔을 \ \ database \ mysql \ schema.inc 포함). PDOException : SQLSTATE [42000] : 구문 오류 또는 액세스 위반 : 1064 SQL 구문에 오류가 있습니다. 'NOT NULL COMMENT'근처에서 사용할 올바른 구문에 대해서는 MySQL 서버 버전에 해당하는 설명서를 확인하십시오. 정수 번호를 저장하는 필드 ', mytextfield VARCHAR'in line 3 : CREATE TABLE {kronos} (fe_id INT 부호없는 NOT NULL auto_increment COMMENT '노드의 기본 식별자', Date NOT NULL COMMENT '정수를 저장하는 필드', mytextfield VARCHAR (50) NOT NULL DEFAULT 'COMMENT'짧은 문자열의 문자열을 저장하는 필드 ', mytext TEXT NOT NULL COMMENT '긴 텍스트를 저장하기위한 필드', PRIMARY KEY (fe_id) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT '예제 테이블.'; db_create_table()의 Array() (C : \ Documents and Settings \ djeewani-si \ Sites \ acquia-drupal \ includes \ database \ database.inc의 2717 줄).모듈에서 날짜 유형을 허용하지 않습니까? 제가 누락 된 다른 오류가 있습니까? 주의 사항 :

+0

어떤 도움이 좋을 것. – user2482358

답변

1

D7 db api에서 날짜 시간 지원이 제거되었습니다.이 기능을 원하면 mysql_type 또는 pgsql_type을 사용하십시오.

이 시도 :

'Date' => array(
    'description' => 'A field for storing date', 
    'type' => 'datetime', 
    'mysql_type' => 'datetime', 
    'not null' => TRUE, 
) 

참조 : https://drupal.org/node/159605

+0

Good Job, It 's Worked .. –