diff --git a/ext/mysql.c b/ext/mysql.c index fb7536a..09acf28 100644 --- a/ext/mysql.c +++ b/ext/mysql.c @@ -1272,7 +1272,8 @@ static VALUE each_hash(int argc, VALUE* argv, VALUE obj) rb_scan_args(argc, argv, "01", &with_table); if (with_table == Qnil) with_table = Qfalse; - process_all_hashes(obj, with_table, 0, 1); + while ((hash = fetch_hash2(obj, with_table)) != Qnil) + rb_yield(hash); return obj; } @@ -2240,7 +2241,7 @@ void Init_mysql(void) rb_define_method(cMysqlRes, "row_tell", row_tell, 0); rb_define_method(cMysqlRes, "each", each, 0); rb_define_method(cMysqlRes, "each_hash", each_hash, -1); - rb_define_method(cMysqlRes, "all_hashes", all_hashes, -1); + /*rb_define_method(cMysqlRes, "all_hashes", all_hashes, -1);*/ /* MysqlField object method */ rb_define_method(cMysqlField, "name", field_name, 0); diff --git a/lib/mysqlplus.rb b/lib/mysqlplus.rb index 76bad4c..474eeb3 100644 --- a/lib/mysqlplus.rb +++ b/lib/mysqlplus.rb @@ -7,3 +7,11 @@ class Mysql get_result end end + +class Mysql::Result + def all_hashes + rows = [] + each_hash { |row| rows << row } + rows + end +end