使用CDbMigration更改表或重置自动增量 [英] Alter table or reset auto-increment using CDbMigration
本文介绍了使用CDbMigration更改表或重置自动增量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用更改表或在Yii 1.x中重置字段的自动增量 href ="http://www.yiiframework.com/doc/api/1.1/CDbMigration/" rel ="nofollow noreferrer"> CDbMigration
?
How can I alter table or reset the auto-increment of a field in Yii 1.x, using CDbMigration
?
我发现 alterColumn
方法同样出色格式为 createTable
, renameTable
和
I found alterColumn
method, as good as createTable
, dropTable
, renameTable
and truncateTable
methods, but either I'm blind or there isn't anything for altering table or resetting the auto-increment of particular column or field.
推荐答案
You can use execute() as Yii defines it:
执行一条SQL语句.此方法使用dbConnection执行指定的SQL语句.
Executes a SQL statement. This method executes the specified SQL statement using dbConnection.
所以
$this->execute("ALTER TABLE tbl_name AUTO_INCREMENT = 1");
这篇关于使用CDbMigration更改表或重置自动增量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文