Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: José Feiteirinha
Fixed multi-line (MEMO) fields [ reply ]  
2011-01-10 16:05
In active_mdb.rb

replace mdb_sql with this one:

def mdb_sql(mdb_file,sql)
# libMDB barks on stderr quite frequently, so discard stderr entirely
command = "mdb-sql -Fp -d '#{DELIMITER}' #{mdb_file} 2> /dev/null \n"
array = []
crow = ""
IO.popen(command, 'r+') do |pipe|
pipe << "#{sql}\ngo\n"
pipe.close_write
pipe.readline
fields = pipe.readline.chomp.split(DELIMITER)
pipe.each do |row|
if (row.split(DELIMITER).length == fields.length)
crow = row
else
crow = crow + row
next unless(crow.split(DELIMITER).size == fields.size)
end
hash = {}
crow = crow.chomp.split(DELIMITER)
fields.each_index do |i|
hash[fields[i]] = crow[i]
end
array << hash
crow = ""
end
end
array
end