D
Dave Lilley
Can anyone here advise me the best way to have two classes access mysql
via a third Mysql DB statements class?
example of what I'm trying to do is below.
I am sure I need to use a pool of connections but am unsure as to how
best to do this.
EVERYTHING works except for this issue.
e.g.
require 'Mysqlclass'
class One
def initialise
@db = Mysqlclass.new ## this connection is the 1st link!
end
end
require 'Mysqlclass'
class Two
def initialise
@db =Mysqlclass.new ## 2nd connection and get a error relating to
this
end
end
Require 'dbi'
class Mysqlclass
def db_connect
@dbh = DBI.connect( ...... )
end
def get_all_recs
@dbh.select_all('select * from a table')
end
#### Other queries etc below here
end
I can get things to work if I change the 2nd script to a method but then
I hit other issues here so would be much happier have multiple
connection allowed.
I've trolled but not found anything that shows me how to do this using
DBI.
I'd sort of expect to have found something like a method or parameter to
use
eg.
DBI.connect(localhost,....,connections <number wanted)
or
DBI.connection = 1 <default> can change to 20
any help be grateful.
dave
via a third Mysql DB statements class?
example of what I'm trying to do is below.
I am sure I need to use a pool of connections but am unsure as to how
best to do this.
EVERYTHING works except for this issue.
e.g.
require 'Mysqlclass'
class One
def initialise
@db = Mysqlclass.new ## this connection is the 1st link!
end
end
require 'Mysqlclass'
class Two
def initialise
@db =Mysqlclass.new ## 2nd connection and get a error relating to
this
end
end
Require 'dbi'
class Mysqlclass
def db_connect
@dbh = DBI.connect( ...... )
end
def get_all_recs
@dbh.select_all('select * from a table')
end
#### Other queries etc below here
end
I can get things to work if I change the 2nd script to a method but then
I hit other issues here so would be much happier have multiple
connection allowed.
I've trolled but not found anything that shows me how to do this using
DBI.
I'd sort of expect to have found something like a method or parameter to
use
eg.
DBI.connect(localhost,....,connections <number wanted)
or
DBI.connection = 1 <default> can change to 20
any help be grateful.
dave