Posted by Sjoerd on 06/20/06 16:57
frothpoker wrote:
> [Very long story about how to store database settings]
I have this database class, where creating an object with
$db = new Database();
either connects to the database or uses the existing database
connection.
class Database {
function Database($database = '') {
$this->user = 'SYSDBA';
$this->password = 'secret';
if (empty($database)) {
$this->database =
'localhost:/var/lib/firebird2/data/pcleden.fdb';
} else {
$this->database = $database;
}
if (isset($GLOBALS['ibase_dbconn'])) {
$this->dbconn = $GLOBALS['ibase_dbconn'];
} else {
$this->connect();
}
}
function connect() {
$res = ibase_connect($this->database,
$this->user,
$this->password);
$GLOBALS['ibase_dbconn'] = $res;
$this->dbconn = $res;
}
function query($sql) {
return ibase_query($this->dbconn, $sql);
}
}
[Back to original message]
|