首页 > 解决方案 > 创建带索引的数组,并与其他数组进行比较

问题描述

我正在尝试创建一个带有索引的数组来搜索值并与来自以下的另一个数组进行比较pgcon

@trunks = []

#trunks local
@trunks_local = []

#dados_local
@bd_local = {}

@c_local = PG.connect(:hostaddr => 'myhost', :port => 5432, :dbname => "testdb", :user => "test", :connect_timeout => 90)

@bd_local = @c_local.exec("SELECT trunk_id, name,phone_number,active FROM callback_trunks")

@bd_local.each.with_index(0) do |h|
  @trunks_local << h
end

这是比较:

@trunks.each.with_index(0) do |trunks|
@trunks_local.each.with_index(0) do |trunk_local|

标签: ruby

解决方案


推荐阅读