3 Nisan 2009 Cuma

some methods implemented in php for PorstgreSQL support

function _connect()
{
if ($this->isVerbose()) {
$this->_errorlog("\n*** Inside database->_connect ***");
}

// Connect to PostreSQL server
$this->_db = pg_connect($this->_host,$this->_user,$this->_pass) or die('Cannot connect to DB server');

if ($this->_postgresql_version == 0) {
preg_match ('/^([0-9]+).([0-9]+).([0-9]+)/', $v, $match);
$v = (intval ($match[1]) * 10000) + (intval ($match[2]) * 100)
+ intval ($match[3]);
}

// Set the database
@pg_select_db($this->_name) or die('error selecting database');

if (!($this->_db)) {
if ($this->isVerbose()) {
$this->_errorlog("\n*** Error in database->_connect ***");
}

// damn, got an error.
$this->dbError();
}

if ($this->_postgresql_version >= 40100) {
if ($this->_charset == 'utf-8') {
@pg_query ("SET NAMES 'utf8'", $this->_db);
}
}

if ($this->isVerbose()) {
$this->_errorlog("\n***leaving database->_connect***");
}
}





Örnek Kod 2

function dbQuery($sql,$ignore_errors=0)
{
if ($this->isVerbose()) {
$this->_errorlog("\n***inside database->dbQuery***");
$this->_errorlog("\n*** sql to execute is $sql ***");
}

// Run query
if ($ignore_errors == 1) {
$result = @pg_query($sql,$this->_db);
} else {
$result = @ pg _query($sql,$this->_db) or die($this->dbError($sql));
}

// If OK, return otherwise echo error
if (empty($result)) {
if ($this->isVerbose()) {
$this->_errorlog("\n***sql ran just fine***");
$this->_errorlog("\n*** Leaving database->dbQuery ***");
}
return $result;

} else {
// callee may want to supress printing of errors
if ($ignore_errors == 1) return false;

if ($this->isVerbose()) {
$this->_errorlog("\n***sql caused an error***");
$this->_errorlog("\n*** Leaving database->dbQuery ***");
}
}
}