开发者

Changing the RoR SQL call to NAME instead of *

Being that it is better to call a SQL database with the specific item, for example:

Bad:

SELECT * FROM tblUsers

Good:

SELECT email FROM tblUsers

How would I do this in开发者_如何学运维 RoR to make it explicitly perform the latter example?


Assuming your tblUsers table is used by User model, you should do

User.all(:select => "email")
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜