public function __construct() { if(!is_array(self::$free)) self::$free = array(); if(!is_array(self::$busy)) self::$busy = array(); $dir = dirname(__FILE__); $conf = parse_ini_file($dir.'/../../../conf/obm_conf.ini'); $this->database = $conf['db']; $this->host = $conf['host']; $this->user = $conf['user']; $this->password = $conf['password']; if(strtoupper($conf['dbtype']) == 'PGSQL') { include_once($dir.'/../lib/pgsql.inc'); } elseif (strtoupper($conf['dbtype']) == 'MYSQL') { include_once($dir.'/../lib/mysql.inc'); } }
public function performUpdate(UpdateObject $updateObj) { $fields = $updateObj->getFields(); $values = $updateObj->getValues(); if (count($fields) != count($values)) { return false; } $setQuery = array(); for ($i = 0; $i < count($fields); $i++) { if ($values[$i] === null) { $setQuery[] = $fields[$i] . "=NULL "; } else { $setQuery[] = $fields[$i] . "='" . $values[$i] . "' "; } } $out = "UPDATE " . $updateObj->getTable() . " "; $out .= "SET " . implode(",", $setQuery) . " "; $out .= "WHERE " . $updateObj->getWhereSentence() . " "; Logger::log($out, __FILE__, __CLASS__, __METHOD__, __LINE__); $res = $this->connection->performQuery($out); if (!$res) { return false; } return pg_affected_rows($res) > 0; }