开发者

Changing the RoR SQL call to NAME instead of *

开发者 https://www.devze.com 2023-01-11 02:50 出处:网络
Being that it is better to call a SQL database with the specific item, for example: Bad: SELECT * FROM tblUsers

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

精彩评论

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