コード例 #1
0
 /**
  * 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
  *                            ),
  *                            'password' => array(
  *                                'type' => 'text',
  *                                'length' => 12
  *                            )
  *                        );
  * @param array $options  An associative array of table options:
  *
  * @return void
  */
 public function createTableSql($name, array $fields, array $options = array())
 {
     $sql = parent::createTableSql($name, $fields, $options);
     foreach ($fields as $fieldName => $field) {
         if (isset($field['autoincrement']) && $field['autoincrement'] || isset($field['autoinc']) && $fields['autoinc']) {
             $sql = array_merge($sql, $this->_makeAutoincrement($fieldName, $name));
         }
     }
     return $sql;
 }