Object to connect to multiple DSNs
Posted: Wed May 11, 2011 12:54 pm
Greetings,
I have an odbc database class that I need to be able to connect to multiple DSN's. What would be the best method to achieve this?
Right now I have the database, user and pass properties defined in the class with constants. I'd like to just add constants for each DSN like:
define('DB1_USER', 'user');
define('DB1_PASSWORD', 'pass');
define('DB1_DSN', 'DRIVER={SQL Server};SERVER=sub.domain.com,1433;DATABASE=database');
define('DB2_USER', 'user');
define('DB2_PASSWORD', 'pass');
define('DB2_DSN', 'DRIVER={SQL Server};SERVER=sub.domain.com,1433;DATABASE=database');
Will a 'db selector' extension work? Should I declare the parent class abstract(havent worked with abstract classes yet)? Or any other suggestion?
I'm just looking for general suggestion, nothing specific, I'll figure that out, part of the learning process...
Thanks,
Matt
I have an odbc database class that I need to be able to connect to multiple DSN's. What would be the best method to achieve this?
Right now I have the database, user and pass properties defined in the class with constants. I'd like to just add constants for each DSN like:
define('DB1_USER', 'user');
define('DB1_PASSWORD', 'pass');
define('DB1_DSN', 'DRIVER={SQL Server};SERVER=sub.domain.com,1433;DATABASE=database');
define('DB2_USER', 'user');
define('DB2_PASSWORD', 'pass');
define('DB2_DSN', 'DRIVER={SQL Server};SERVER=sub.domain.com,1433;DATABASE=database');
Will a 'db selector' extension work? Should I declare the parent class abstract(havent worked with abstract classes yet)? Or any other suggestion?
I'm just looking for general suggestion, nothing specific, I'll figure that out, part of the learning process...
Thanks,
Matt