Reply to Re: using global variables in the database connection string

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация