2011-08-18 53 views
4

我有以下代碼:Symfony的學說查詢錯誤

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

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

而且通過主義產生的查詢是:

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') 

在這可能是錯誤的事情是列,數字的不幸的名字。我不得不使用數字,因爲它使事情很多更容易。

我該怎麼做才能生成一個查詢,其列名在「`」之間?

+4

查看生成的類,看看是否可以將'列名'。但如果它不起作用 - 我根本不爲你感到難過。沒有足夠的懲罰來命名你這樣的專欄。不,它不會讓事情變得更容易(正如你可以清楚地看到的那樣)。 – fdreger

回答