/** * create a new table * * @param string $name Name of the database that should be created * @param array $fields Associative array that contains the definition of each field of the new table * The indexes of the array entries are the names of the fields of the table an * the array entry values are associative arrays like those that are meant to be * passed with the field definitions to get[Type]Declaration() functions. * * Example * array( * * 'id' => array( * 'type' => 'integer', * 'unsigned' => 1, * 'notnull' => 1, * 'default' => 0, * ), * 'name' => array( * 'type' => 'text', * 'length' => 12, * ), * 'description' => array( * 'type' => 'text', * 'length' => 12, * ) * ); * @param array $options An associative array of table options: * * @return void */ public function createTable($name, array $fields, array $options = array()) { parent::createTable($name, $fields, $options); // TODO ? $this->_silentCommit(); foreach ($fields as $field_name => $field) { if (!empty($field['autoincrement'])) { //create PK constraint $pk_definition = array('fields' => array($field_name => array()), 'primary' => true); //$pk_name = $name.'_PK'; $pk_name = null; $result = $this->createConstraint($name, $pk_name, $pk_definition); //create autoincrement sequence + trigger return $this->_makeAutoincrement($field_name, $name, 1); } } }