我正在学习 ruby 和 ruby on rails,我有一个问题:
我想知道我是否可以在 pgresult 上使用 select 方法。
这是我的代码:
connection = ActiveRecord::Base.connection()
allinfosql = "SELECT applications.appli_name, folders.folder_name, folders.is_obsolete, strategies.strategy_name
FROM applications, folders, strategies, folders_strategies
WHERE strategies.id = folders_strategies.strategy_id
AND folders_strategies.folder_id = folders.id
AND folders.application_id = applications.id
ORDER BY applications.appli_name, folders.folder_name ASC"
@allinfos = connection.execute(allinfosql)
我试着这样做
test = @allinfos.select {|row| row['appli_name']="SOME_VALUE"}
但结果是 test 等于 @allinfos
谢谢你的帮助