MySQL错误-SQLSTATE [42000]:语法错误或访问冲突:1064
我已经浏览了建议的代码,但是找不到解决该问题的答案,所以我问了一下.
I've looked through the suggested code and cannot find an answer that fixes the problem so I am asking away.
我正在使用MAMP v2.0.5,MySQL v5.5.9,PHP v5.3.6(根据MAMP,根据OS X为v5.3.8)和FuelPHP v1.1,并且是框架的新手. .本教程的一部分要求使用石油"来进行迁移以更新项目.定义了表后,迁移将应用SQL生成表.这样做时,我会收到上述错误.浏览生成的代码后,我找不到任何错误(也许我遗漏了一些明显的东西).我正在使用PDO,并且还检查了我的sql_mode = ''
,它确实在工作.从命令行和phpMyAdmin运行MySQL查询可以确认这一点.我认为这是MySQL错误,而不是FuelPHP/oil问题.有人有什么建议吗?
I am using MAMP v2.0.5, MySQL v5.5.9, PHP v5.3.6 (according to MAMP, v5.3.8 according to OS X) and FuelPHP v1.1, and being new to frameworks I am working through a tutorial. Part of the tutorial requires the use of 'oil' to carry out migrations to update the project. Having defined a table, the migration applies the SQL to generate the table. When I do so, I get the above error. Having looked through the generated code I can't find any errors (maybe I am missing something obvious). I am using PDO and have also checked that my sql_mode = ''
, which it does. Running a MySQL query from the command line and phpMyAdmin confirms this. I think this is a MySQL error and not a problem with FuelPHP/oil. Does anybody have any suggestions?
生成的SQL:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varhcar(50) NOT NULL,
`password` varchar(255) NOT NULL,
`group` int(11) NOT NULL,
`email` varchar(255) NOT NULL,
`last_login` int(11) NOT NULL,
`login_hash` varchar(255) NOT NULL,
`profile_fields` text NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
PRIMARY KEY `id` (`id`)
) DEFAULT CHARACTER SET utf8;
错误:
bash:blog me$ oil refine migrate
Error - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varhcar(50) NOT NULL,
`password` varchar(255) NOT NULL,
`group` int(11) NOT NU' at line 3 with query: "CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varhcar(50) NOT NULL,
`password` varchar(255) NOT NULL,
`group` int(11) NOT NULL,
`email` varchar(255) NOT NULL,
`last_login` int(11) NOT NULL,
`login_hash` varchar(255) NOT NULL,
`profile_fields` text NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
PRIMARY KEY `id` (`id`)
) DEFAULT CHARACTER SET utf8;" in COREPATH/classes/database/pdo/connection.php on line 137
您输入了错字:
`username` varhcar(50) NOT NULL,
应为:
`username` varchar(50) NOT NULL,