[英]Rails Mysql Results - fetch_fields method
So I'm trying to get the column names from the sql results using the method fetch_fields. 所以我试图使用方法fetch_fields从sql结果中获取列名。 But that returns it in this odd way: 但这以一种奇怪的方式返回了它:
> for keys in e.fetch_fields.each do
> puts keys
> end
#<Mysql::Field:0x1c2a7bc>
#<Mysql::Field:0x1c2a780>
#<Mysql::Field:0x1c2a744>
=> [#<Mysql::Field:name>, #<Mysql::Field:address>, #<Mysql::Field:city>]
How do I get it to show as name, address, city? 如何显示为名称,地址,城市?
Found that this is the correct way to get the names of each field: 发现这是获取每个字段名称的正确方法:
> for keys in e.fetch_fields.each do
> puts keys.name
> end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.