dbHost = $dbHost : $this->dbHost = DBHOST; ($dbUser != '') ? $this->dbUser = $dbUser : $this->dbUser = DBUSER; ($dbPass != '') ? $this->dbPass = $dbPass : $this->dbPass = DBPASS; ($dbPort != '') ? $this->dbPort = $dbPort : $this->dbPort = DBPORT; ($dbName != '') ? $this->dbName = $dbName : $this->dbName = DBNAME; try { $this->dbConn = new PDO("pgsql:host=". $this->dbHost .";port=". $this->dbPort .";dbname=". $this->dbName, $this->dbUser, $this->dbPass); $this->dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { $lastError = $e->getMessage(); return -1; } } public function __destruct() { $this->dbConn = NULL; } public function __set($name, $value) { $this->$name = $value; } public function sqlExec($query, $params = '') { $stmt = ''; try { if($params != '') { $stmt = $this->dbConn->prepare($query); $stmt->execute($params); return $stmt->fetchAll(PDO::FETCH_ASSOC); }else{ $stmt = $this->dbConn->prepare($query); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_ASSOC); } } catch (PDOException $e) { $lastError = $e->getMessage(); return -1; } } public function getLastError() { return $this->lastError; } } ?>