From 78a208d40c28319310b7770f69ad976acb9b7d3c Mon Sep 17 00:00:00 2001 From: sunnyalways <1459118394@qq.com> Date: Fri, 23 Oct 2020 15:59:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=BA=E8=A1=A8=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=B5=B7=E5=A7=8B=E8=87=AA=E5=A2=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phinx/src/Phinx/Db/Adapter/MysqlAdapter.php | 5 +++++ src/db/Table.php | 11 +++++++++++ 2 files changed, 16 insertions(+) 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