diff --git a/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php b/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php index 37710a6..77b81e6 100644 --- a/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php +++ b/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php @@ -246,6 +246,11 @@ public function createTable(Table $table) $optionsStr .= sprintf(' COLLATE %s', $options['collation']); } + // set the table auto_increment + if (isset($options['auto_increment'])) { + $optionsStr .= sprintf(' AUTO_INCREMENT = %s', $options['auto_increment']); + } + // set the table comment if (isset($options['comment'])) { $optionsStr .= sprintf(" COMMENT=%s ", $this->getConnection()->quote($options['comment'])); diff --git a/src/db/Table.php b/src/db/Table.php index cf4daa9..ce30a5f 100644 --- a/src/db/Table.php +++ b/src/db/Table.php @@ -48,6 +48,17 @@ public function setEngine($engine) return $this; } + /** + * 设置起始自增值 + * @param integer $auto_increment + * @return $this + */ + public function setAutoIncrement($auto_increment) + { + $this->options['auto_increment'] = $auto_increment; + return $this; + } + /** * 设置表注释 * @param $comment