Title should be "Am I creating too manY MySQL connections?
All my mySQL table query classes extend my root class which establishes a connection. Should I be establishing a singleton class, a “require_once” or am I ok?
Here is my root class
Abstract Class scheduler_root_module_db {
Protected $dbcnx;
Protected $pServer = // <omitted for this sitepoint thread>
Protected $pUsername // <omitted>
Protected $pPassword = // <omitted>
Protected $pDataBaseName = //<omitted>
Public Function __Construct() {
// Purpose: Prepare the database for i/o
// Requires: active server and database
// Returns: Database object
// On Error: ends session
// connect to the server
$this->dbcnx = @mysql_connect($this->pServer, $this->pUsername, $this->pPassword);
if (!$this->dbcnx){
exit('<p>Unable to connect to the database server.</p>');
} // end if
// select the database
if (!mysql_select_db($this->pDataBaseName)) {
exit(mysql_error($this->dbcnx));
} // end if
} // end Function __Construct
Thanks,
grNadpa
(irrelevant note: Ultimately I plan to Throw an error rather than simply exit ).