Symfony Doctrine查询错误

时间:2011-08-18 09:55:42

标签: php sql symfony1 doctrine symfony-1.4

我有以下代码:

$getmoney = Doctrine::getTable('Countries')->find(1);

$insertmoney = new Accounts();
$insertmoney->userid = $userid;
$insertmoney[$getmoney->getCurrency()] = $getmoney->getBaby(); 
$insertmoney->save();

Doctrine生成的查询是:

INSERT INTO accounts (1, userid, 2) VALUES ('0', '31', '15')

但似乎有一个SQL错误: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 '1, userid, 2) VALUES ('0', '31', '15')' at line 1

相关性查询将是:

INSERT INTO accounts (`1`, `userid`, `2`) VALUES ('0', '31', '15')

这可能是错误的是列数字的不幸名称。我不得不使用数字,因为它使很多更容易。

如何生成“`”之间列名称的查询?

1 个答案:

答案 0 :(得分:5)

哇......真的很不​​幸! 无论如何......你可以configure identifier quoting以便总是使用反引号。