/** * Constructor * * @param ADOConnection $db An instance of ADOConnection. * * @throws XML_Query2XML_DBException If the ADOConnection instance passed as * argument was not connected to the database server. */ public function __construct(ADOConnection $db) { if (!$db->IsConnected()) { throw new XML_Query2XML_DBException('ADOConnection instance was not connected'); } $db->SetFetchMode(ADODB_FETCH_ASSOC); $this->_db = $db; }
/** * Create DB connection */ protected function connect() { /** @var $this->connection \ADOConnection */ $this->connection =& NewADOConnection($this->driver); $host = $this->host; if ($this->port) { $host .= ':' . $this->port; } // connect if ($this->db) { $this->connection->Connect($host, $this->user, $this->password, $this->db); } else { $this->connection->Connect($host, $this->user, $this->password); } // check connection if (!$this->connection->IsConnected()) { $errMsg = $this->connection->ErrorMsg(); $this->utilityFuncs->throwException('db_connection_failed', $errMsg); } // execute initial statement if ($this->setDBinit) { $this->utilityFuncs->debugMessage('sql_request', [$this->setDBinit]); $this->connection->Execute($this->setDBinit); // error occured? if ($this->connection->ErrorNo() != 0) { $errMsg = $this->connection->ErrorMsg(); $this->utilityFuncs->debugMessage('sql_request_error', [$errMsg], 3); } } }