Joe*_*Joe 1 php mysql migration yii
我正在尝试使用Yii进行迁移并在up()方法中创建新表.只要我不添加该ENGINE=InnoDB子句,它就可以正常工作.在那种情况下 - 它给了我一个错误near ENGINE.
public function up()
{
$this->createTable('tbl_project', array(
'id' => 'pk',
'name' => 'string NOT NULL',
'description' => 'text NOT NULL',
'create_time' => 'datetime DEFAULT NULL',
'create_user_id' => 'int(11) DEFAULT NULL',
'update_time' => 'datetime DEFAULT NULL',
'update_user_id' => 'int(11) DEFAULT NULL',
), 'ENGINE=InnoDB');
}
Run Code Online (Sandbox Code Playgroud)
我的Yii版本是1.1.12.PHP 5.4.3,MySQL 5.5.24.
这是一些Yii bug吗?
编辑(yii bug描述):
*** applying m130208_133533_create_table_project
> create table tbl_project ...exception 'CDbException' with message 'CDbComm
and failed to execute the SQL statement: CDbCommand failed to prepare the SQL st
atement: SQLSTATE[HY000]: General error: 1 near "engine": syntax error. The SQL
statement executed was: CREATE TABLE 'tbl_project' (
"id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
"name" varchar(255) NOT NULL,
"description" text NOT NULL,
"create_time" datetime DEFAULT NULL,
"create_user_id" int(11) DEFAULT NULL,
"update_time" datetime DEFAULT NULL,
"update_user_id" int(11) DEFAULT NULL
) engine = InnoDB' in C:\wamp\yii\framework\db\CDbCommand.php:357
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,通过检查console.php和main.php中的数据库配置是否相同来解决
i.e 'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=databasename',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'ur password',
'charset' => 'utf8',
),
Run Code Online (Sandbox Code Playgroud)
并注释两个文件中的sqlite行
| 归档时间: |
|
| 查看次数: |
2339 次 |
| 最近记录: |