Alter table or reset auto-increment using CDbMigration

柔情痞子 提交于 2019-12-24 05:21:27

问题


How can I alter table or reset the auto-increment of a field in Yii 1.x, using CDbMigration?

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.


回答1:


You can use execute() as Yii defines it:

Executes a SQL statement. This method executes the specified SQL statement using dbConnection.

So,

$this->execute("ALTER TABLE tbl_name AUTO_INCREMENT = 1");


来源:https://stackoverflow.com/questions/27402950/alter-table-or-reset-auto-increment-using-cdbmigration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!