FAQ |
Kalender |
|
Ämnesverktyg | Visningsalternativ |
![]() |
#22 | ||
|
|||
Klarade millennium-buggen
|
Citat:
Trodde det var rdbi, interface mot MySQL..... Men den gnäller fortfarande på namespace.... Följande kod har jag att testa med: Kod:
#!ruby20 # encoding: utf-8 =begin = Description The DBI package is a vendor independent interface for accessing databases. It is similar, but not identical to, Perl's DBI module. <DDL-script> delimiter $$ CREATE TABLE `players` ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(32) NOT NULL, `lastname` varchar(32) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=430 DEFAULT CHARSET=latin1$$ </DDL-script> = Synopsis =end require 'rdbi\dbi' # Same example, but a little more Ruby-ish class Main def initialize() @connectionstring = 'DBI:Mysql:test' @user = 'root' @password = '**************' test() end def test() @dbh = connect() select() end def connect() DBI.connect(connectionstring, user, password) do | dbh | return dbh end def select() @dbh.select_all('select * from players') do | row | puts row end end end Main.new() Jag har lagt in lib filerna från "rdbi-1.2.0.pre0" till Rubys lib-katalog. Har även lagt in lib-filerna från "rdbi-driver-mysql-master" till Rubys lib-katalog. Har även kopierat in libmysql.dll i Ruby\bin från MySQL\lib. Men namespace rdbi\dbi hittas inte.... Senast redigerad av Conny Westh den 2013-07-03 klockan 22:31 |
||
![]() |
![]() |
|
|