试图找出在phinx包中事务是如何工作的。这是我的迁移代码,它不起作用。我使用mysql,phinx.yml一切都很好。因此,表acme是在表fail失败时创建的,在phinxlog表中找不到任何记录。所以,当我运行phinx migrate时,我出现了错误SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'acme' already exists。那么,我如何使用事务呢?我没有找到任何关于这件事的文档,请帮帮我)
public function up()
{
$this->getAdapter()->beginTransaction();
$this->table('acme')->addColumn('name', 'string')->create();
$this->table('fail')->addColumn('lal', 'failme')->create();
$this->getAdapter()->commitTransaction();
}发布于 2016-10-21 15:54:18
事务只适用于mysql中的数据(DML)更改。您不能“处理”数据定义更改(DDL)。
http://dev.mysql.com/doc/refman/5.7/en/cannot-roll-back.html
但其他DBs可以(在特定条件下)。
Is it possible to roll back CREATE TABLE and ALTER TABLE statements in major SQL databases?
https://stackoverflow.com/questions/40143078
复制相似问题