Drupal 7中的Mysql语法错误
我试图使用外键定义表之间的关系 在drupal 7中。我使用hook_模式和hook_更新函数来定义 更新架构。我得到以下错误 失败:PDO异常:SQLSTATE[42000]:语法错误或访问 违反:1064您的SQL语法有错误;检查手册 对应于MySQL服务器版本的正确语法 使用near'DEFAULT NULL)引擎=InnoDB默认字符集utf8 注释第5行的“表格:创建表格” {organization}(Drupal 7中的Mysql语法错误,drupal,mysql-error-1064,Drupal,Mysql Error 1064,我试图使用外键定义表之间的关系 在drupal 7中。我使用hook_模式和hook_更新函数来定义 更新架构。我得到以下错误 失败:PDO异常:SQLSTATE[42000]:语法错误或访问 违反:1064您的SQL语法有错误;检查手册 对应于MySQL服务器版本的正确语法 使用near'DEFAULT NULL)引擎=InnoDB默认字符集utf8 注释第5行的“表格:创建表格” {organization}(idINT unsigned NOT NULL 自动递增注释“关系的主标识符”,
id
INT unsigned NOT NULL
自动递增注释“关系的主标识符”,
uid
INT unsigned NULL DEFAULT 0 COMMENT'的主标识符
用户/员工',oid
INT unsigned NULL默认值0注释'
雇用员工的部门标识符,主键
默认值
NULL)引擎=InnoDB默认字符集utf8注释“表格”
雇员与组织的关系";;中的数组()
db_create_table()(第2717行)
C:\xampp\htdocs\tutumuudit\includes\database\database.inc)
我自己解决的。我把那些键放在字段数组下。
那太愚蠢了,我花了两个小时才弄清楚。决赛
代码如下:
$schema['relationship] = array(
'description' => 'The table for employee organisation relationship',
'fields' => array(
'rid' => array(
'description' => 'The primary Identifier for a Relationship.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The primary Identifier for User/Employee',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
),
'oid' => array(
'description' => 'The department Identifier of employee employed',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
),
'indexes' => array(
'uid' => array('uid'),
'oid' => array('oid'),
),
'foreign keys' => array(
'uid' => array(
'table' => 'users',
'columns' => array('uid' => 'uid')
),
'oid' => array(
'table' => 'organization',
'columns' => array('oid' => 'oid')
),
),
'primary key' => array('rid'),
)
);
$schema['relationship] = array(
'description' => 'The table for employee organisation relationship',
'fields' => array(
'rid' => array(
'description' => 'The primary Identifier for a Relationship.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The primary Identifier for User/Employee',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
),
'oid' => array(
'description' => 'The department Identifier of employee employed',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
),
),
'indexes' => array(
'uid' => array('uid'),
'oid' => array('oid'),
),
'foreign keys' => array(
'uid' => array(
'table' => 'users',
'columns' => array('uid' => 'uid')
),
'oid' => array(
'table' => 'organization',
'columns' => array('oid' => 'oid')
),
),
'primary key' => array('rid'),
);