Daniel
Daniel

Reputation: 418

Symfony Doctrine query error

I have the following code:

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

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

And the query generated by Doctrine is:

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

But it seems to have a SQL error: 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

The correcy query would be:

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

Probably the wrong thing in this is the unfortunate names of the columns, numbers. I had to use numbers only because it make thing a lot easier.

What can I do to generate a query that has the columns' names between " ` " ?

Upvotes: 4

Views: 549

Answers (1)

greg0ire
greg0ire

Reputation: 23265

Wow... that's quite unfortunate, indeed! Anyway... you may configure identifier quoting so that you always use backticks.

Upvotes: 3

Related Questions