From: Kashia Buch Date: 2006-12-13T04:23:21+09:00 Subject: Re: connect to MySQL Database Hi, >> class ClamavScanResult >> is Timestamped >> property :path, String >> property :result, String >> end ^^ that should've said String there, sorry. >> Og.start(:store => :mysql, :name => 'clamavdb', :user => 'testuser', >> :password => 'private', :classes => [ClamavScanResult]) > Great, I will give it a try. Seems to be exactly what I need. > > But what do I need to connect to a MySQL database? > > > mysql_connect(...... > mysql_select_database(..... > mysql_query(------- > > ....display results in a html-table... > ?> > > > Has ruby no native MySQL support. Do I need to install extra modules, > libs ?? For my 'idea' you only need 'Og' (gem install og) and it's dependencies. It comes with a built in mysql lib, so for your case not even a mysql lib is required. Og just needs the username (:user), password (:password) and the table (:name) to connect to any of its supported database systems. My idea also includes, that you have _nothing_ do with the 'database', which is handles by Og (silently). To use a database is merely a way to structure data, which Og does quite nicely. I see you're using erb/eruby/erubis/mod_ruby (unsure, never used either)? Or are you using Rails (which I also never used and comment on either)? This part would then just 'display' what is in the database. What I posted you, would basically be the creating the data in the database. On to how to display it using erb: # hypothetical display.erb :mysql, :name => 'clamavdb', :user => 'testuser', :password => 'private', :classes => [ClamavScanResult]) # scans is just a array with ClamavScanResult instances scans = ClamavScanResult.all ?>
FileStatus
__END__ Well, or something along those lines. Note that this is probably _not_ compatible with rails. I can elaborate on I myself would do the display part if you want me to. Hope that helps. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/