开发者

Doctrine 2 Model: How set table name with "-" in it?

开发者 https://www.devze.com 2023-01-27 03:22 出处:网络
How should I name a Doctrine 2 Model table row variable (e.g. url-name is the table row name) and I tried it with that:

How should I name a Doctrine 2 Model table row variable (e.g. url-name is the table row name) and I tried it with that:

/** @Column(name="url-name", type="string") */
private $urlName;

// or I tri开发者_开发技巧ed also

/** @Column(name="`url-name`", type="string") */
private $url_name;

But it doesn't fetch the $urlName row (this row result is empty but other rows/the rest is fetched correct).


You cannot use minus character as a part of column name. Just take a look at this query:

SELECT url-name ...

It means substract name from url just like price * tax means multiply price by tax. Use _ instead of -.

0

精彩评论

暂无评论...
验证码 换一张
取 消