install file giving me:

Warning: Invalid argument supplied for foreach() in _drupal_schema_initialize() (line 7133 of C:\www\BARC7\includes\common.inc).
Warning: Invalid argument supplied for foreach() in _drupal_schema_initialize() (line 7133 of C:\www\BARC7\includes\common.inc).

I don't see them...


function membership_schema() {
  $schema['membership_member_info'] = array(
     'uid' => array(
        'description' => 'user ID.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'first_name' => array(
        'description' => 'Members first name.',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
      ),
	  'last_name' => array(
        'description' => 'Members last name.',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
      ),
	  'call_sign' => array(
        'description' => 'Members call sign.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
	  'email' => array(
        'description' => 'Members email.',
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
        'default' => '',
      ),
	  'arrl' => array(
        'description' => 'Is member an ARRL member.',
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => '',
      ),
	  'address' => array(
        'description' => 'Address.',
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
        'default' => '',
      ),
	  'city' => array(
        'description' => 'Address city.',
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
        'default' => '',
      ),
	  'state' => array(
        'description' => 'Address state.',
        'type' => 'varchar',
        'length' => 10,
        'not null' => TRUE,
        'default' => '',
      ),
	  'zip' => array(
        'description' => 'Address zip.',
        'type' => 'int',
        'length' => 5,
        'not null' => TRUE,
        'default' => '',
      ),
	  'primary_phone' => array(
        'description' => 'Primary contact phone number.',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
      ),
	  'alt_phone' => array(
        'description' => 'Alternate contact phone number.',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        'default' => '',
      ),
	  'membership_type' => array(
        'description' => 'Members membership type.',
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
        'default' => '',
      ),
	  'notes' => array(
        'description' => 'Notes about this member.',
        'type' => 'varchar',
		'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
	  'application_date' => array(
        'description' => 'The date the application for membership was submitted.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
	  'join_date' => array(
        'description' => 'The date member was approved for membership.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    );
    
  return $schema;
}

Comments

Jaypan’s picture

The format should be:

$schema['schema_name'] = array
(
  'fields' => array
  (
    // All your fields go here
  ),
);

You are missing the 'fields' key.

Me’s picture

Thank you!

Me’s picture

So I am not getting the errors now, but it is also not creating the table in the db.

I am um-installing the module and then re-installing it but no table is created.

Revised .install file:

function membership_schema() {
  $schema['membership_member_info'] = array
  (
		'fields' => array
		(
		// all our fields start here
		   'uid' => array(
			'description' => 'user ID.',
			'type' => 'serial',
			'not null' => TRUE,
			),
			'first_name' => array(
				'description' => 'Members first name.',
				'type' => 'varchar',
				'length' => 50,
				'not null' => TRUE,
				'default' => '',
			),
			'last_name' => array(
				'description' => 'Members last name.',
				'type' => 'varchar',
				'length' => 50,
				'not null' => TRUE,
				'default' => '',
			),
			'call_sign' => array(
				'description' => 'Members call sign.',
				'type' => 'varchar',
				'length' => 20,
				'not null' => TRUE,
				'default' => '',
			),
			'email' => array(
				'description' => 'Members email.',
				'type' => 'varchar',
				'length' => 100,
				'not null' => TRUE,
				'default' => '',
			),
			'arrl' => array(
				'description' => 'Is member an ARRL member.',
				'type' => 'varchar',
				'length' => 20,
				'not null' => TRUE,
				'default' => '',
			),
			'address' => array(
				'description' => 'Address.',
				'type' => 'varchar',
				'length' => 100,
				'not null' => TRUE,
				'default' => '',
			),
			'city' => array(
				'description' => 'Address city.',
				'type' => 'varchar',
				'length' => 100,
				'not null' => TRUE,
				'default' => '',
			),
			'state' => array(
				'description' => 'Address state.',
				'type' => 'varchar',
				'length' => 10,
				'not null' => TRUE,
				'default' => '',
			),
			'zip' => array(
				'description' => 'Address zip.',
				'type' => 'int',
				'length' => 5,
				'not null' => TRUE,
				'default' => '',
			),
			'primary_phone' => array(
				'description' => 'Primary contact phone number.',
				'type' => 'varchar',
				'length' => 50,
				'not null' => TRUE,
				'default' => '',
			),
			'alt_phone' => array(
				'description' => 'Alternate contact phone number.',
				'type' => 'varchar',
				'length' => 50,
				'not null' => TRUE,
				'default' => '',
			),
			'membership_type' => array(
				'description' => 'Members membership type.',
				'type' => 'varchar',
				'length' => 100,
				'not null' => TRUE,
				'default' => '',
			),
			'notes' => array(
				'description' => 'Notes about this member.',
				'type' => 'varchar',
				'length' => 255,
				'not null' => TRUE,
				'default' => '',
			),
			'application_date' => array(
				'description' => 'The date the application for membership was submitted.',
				'type' => 'varchar',
				'length' => 255,
				'not null' => TRUE,
				'default' => '',
			),
			'join_date' => array(
				'description' => 'The date member was approved for membership.',
				'type' => 'varchar',
				'length' => 255,
				'not null' => TRUE,
				'default' => '',
			  ),
		),
	);
  return $schema;
}
Jaypan’s picture

Are you just disabling the module, or completely uninstalling it? You need to disable it then uninstall it, then re-enable it.

Me’s picture

I uninstalled then reinstalled and it tried to make the table but now I get:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key: CREATE TABLE {membership_member_info} ( `id` INT unsigned NOT NULL auto_increment, `first_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'Members first name.', `last_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'Members last name.', `call_sign` VARCHAR(20) NOT NULL DEFAULT '' COMMENT 'Members call sign.', `email` VARCHAR(100) NOT NULL DEFAULT '' COMMENT 'Members email.', `arrl` VARCHAR(20) NOT NULL DEFAULT '' COMMENT 'Is member an ARRL member.', `address` VARCHAR(100) NOT NULL DEFAULT '' COMMENT 'Address.', `city` VARCHAR(100) NOT NULL DEFAULT '' COMMENT 'Address city.', `state` VARCHAR(10) NOT NULL DEFAULT '' COMMENT 'Address state.', `zip` INT NOT NULL DEFAULT '' COMMENT 'Address zip.', `primary_phone` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'Primary contact phone number.', `alt_phone` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'Alternate contact phone number.', `membership_type` VARCHAR(100) NOT NULL DEFAULT '' COMMENT 'Members membership type.', `notes` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'Notes about this member.', `application_date` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'The date the application for membership was submitted.', `join_date` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'The date member was approved for membership.' ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8; Array ( ) in db_create_table() (line 2720 of C:\wamp\www\BARC7\includes\database\database.inc).

so what is wrong with the "id " field...

Jaypan’s picture

You've defined uid as a serial field, so this must also be the primary key:

$schema['membership_member_info'] = array
(
  'fields' => array
  (

  ),
  'primary key' => array('uid'),
);
Me’s picture

I did try to define a primary key but I had it with the field options, not the table.

Last question, how do I include more tables?

function membership_schema() {
$schema['table_1'] = array
(
  'fields' => array
  (
    // All your fields go here
  ),
);

$schema['table_2'] = array
(
  'fields' => array
  (
    // All your fields go here
  ),
);
 
return $schema;
}

Jaypan’s picture

Just like that.