gpt4 book ai didi

php - 使用 ENGINE 子句在迁移中创建表失败

转载 作者:行者123 更新时间:2023-11-29 03:50:40 25 4
gpt4 key购买 nike

我正在尝试使用 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');
}

我的 Yii 版本是 1.1.12。 PHP 5.4.3、MySQL 5.5.24。

那是 Yii 的错误吗?

编辑(yii 错误描述):

*** 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

最佳答案

我有同样的问题,通过检查 console.php 和 main.php 中数据库的配置是否相同解决了

i.e 'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=databasename',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'ur password',
'charset' => 'utf8',
),

并注释掉两个文件中的sqlite行

关于php - 使用 ENGINE 子句在迁移中创建表失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14774895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com