Skip to main content
Bumped by Community user
removed "Drupal" from the title; added a more explicit question; edited tags
Source Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284

Drupal Schema Syntax Error Why am I getting this error for the schema I define in my module?

I'm building a module for Drupal 7, but having troubleI have troubles with my schema, and can't see what the issue isI don't understand why.

This is my schema.

ThenI get this is the error I'm getting.

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 'NULL DEFAULT NULL, `end_time` NULL DEFAULT NULL, `duration` INT unsigned NOT ' at line 5: CREATE TABLE {table_name} ( `id` INT unsigned NOT NULL auto_increment, `nid` INT unsigned NOT NULL, `oid` INT unsigned NOT NULL, `start_time` NULL DEFAULT NULL, `end_time` NULL DEFAULT NULL, `duration` INT unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `0` () ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8; Array ( ) in db_create_table() (line 2717 of /Applications/MAMP/htdocs/project/www/includes/database/database.inc). 

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 'NULL DEFAULT NULL, end_time NULL DEFAULT NULL, duration INT unsigned NOT ' at line 5: CREATE TABLE {table_name} ( id INT unsigned NOT NULL auto_increment, nid INT unsigned NOT NULL, oid INT unsigned NOT NULL, start_time NULL DEFAULT NULL, end_time NULL DEFAULT NULL, duration INT unsigned NOT NULL, PRIMARY KEY (id), UNIQUE KEY 0 () ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8; Array ( ) in db_create_table() (line 2717 of /Applications/MAMP/htdocs/project/www/includes/database/database.inc).

Been trying to work out what's wrong for a while now, any help will be appreciated!How can I fix this error?

Drupal Schema Syntax Error

I'm building a module for Drupal 7 but having trouble with my schema and can't see what the issue is.

This is my schema

Then this is the error I'm getting

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 'NULL DEFAULT NULL, `end_time` NULL DEFAULT NULL, `duration` INT unsigned NOT ' at line 5: CREATE TABLE {table_name} ( `id` INT unsigned NOT NULL auto_increment, `nid` INT unsigned NOT NULL, `oid` INT unsigned NOT NULL, `start_time` NULL DEFAULT NULL, `end_time` NULL DEFAULT NULL, `duration` INT unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `0` () ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8; Array ( ) in db_create_table() (line 2717 of /Applications/MAMP/htdocs/project/www/includes/database/database.inc). 

Been trying to work out what's wrong for a while now, any help will be appreciated!

Why am I getting this error for the schema I define in my module?

I'm building a module for Drupal 7, but I have troubles with my schema, and I don't understand why.

This is my schema.

I get this error.

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 'NULL DEFAULT NULL, end_time NULL DEFAULT NULL, duration INT unsigned NOT ' at line 5: CREATE TABLE {table_name} ( id INT unsigned NOT NULL auto_increment, nid INT unsigned NOT NULL, oid INT unsigned NOT NULL, start_time NULL DEFAULT NULL, end_time NULL DEFAULT NULL, duration INT unsigned NOT NULL, PRIMARY KEY (id), UNIQUE KEY 0 () ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8; Array ( ) in db_create_table() (line 2717 of /Applications/MAMP/htdocs/project/www/includes/database/database.inc).

How can I fix this error?

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited tags
Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284
Source Link

Drupal Schema Syntax Error

I'm building a module for Drupal 7 but having trouble with my schema and can't see what the issue is.

This is my schema

$schema['table_name'] = array( 'fields' => array( 'id' => array( 'type' => 'serial', 'unsigned' => true, 'not null' => true, 'length' => 11 ), 'nid' => array( 'type' => 'int', 'unsigned' => true, 'not null' => true, 'length' => 11 ), 'oid' => array( 'type' => 'int', 'unsigned' => true, 'not null' => true, 'length' => 11 ), 'start_time' => array( 'type' => 'datetime', 'not null' => false ), 'end_time' => array( 'type' => 'datetime', 'not null' => false ), 'duration' => array( 'type' => 'int', 'unsigned' => true, 'not null' => true, 'length' => 11 ) ), 'primary key' => array('id'), 'unique keys' => array('id') ); 

Then this is the error I'm getting

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 'NULL DEFAULT NULL, `end_time` NULL DEFAULT NULL, `duration` INT unsigned NOT ' at line 5: CREATE TABLE {table_name} ( `id` INT unsigned NOT NULL auto_increment, `nid` INT unsigned NOT NULL, `oid` INT unsigned NOT NULL, `start_time` NULL DEFAULT NULL, `end_time` NULL DEFAULT NULL, `duration` INT unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `0` () ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8; Array ( ) in db_create_table() (line 2717 of /Applications/MAMP/htdocs/project/www/includes/database/database.inc). 

Been trying to work out what's wrong for a while now, any help will be appreciated!