Jack Dempsey wrote:
> Matz,
> 
> Its here, finally :-) Its been hard to actually code this stuff because every two
> seconds I'm picking it up look up some syntax or method...
> 
> I'm trying to familiarize myself with the ruby way, and although I could figure
> out a boring C style way of doing this, I'm wondering how I can do it with
> blocks...
> the basic idea is that this script will take a database and a table (if given)
> grab the types of the fields and populate it with random data...good for getting
> stuff setup quickly...when i get it done i'd be happy to send it to the
> list....so, onto the code....
> 
> So, what i'd like to do is this:
> 
> m = Mysql.new(host, user, passwd, db)
> 
> if defined? table
>      m.list_fields(table).fetch_fields.each do |f|
>           puts f.name
>      end
> else
>     m.list_tables.each do |table|
>         m.list_fields(table).fetch_fields.each do |f|
>           puts f.name
>         end
>     end
> end

 m = Mysql.new(host, user, passwd, db)
 
 tables = defined?(table) ? [table] : m.list_tables

 tables.each do |table|
   m.list_fields(table).fetch_fields.each do |f|
     puts f.name
   end
 end


Regards,

  Michael
-- 
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de