34 require_once (dirname(__FILE__) .
'/../TestEnvironment.php');
35 require_once (dirname(__FILE__) .
'/../../ui/common/common-ui.php');
51 function __construct($options = NULL) {
56 if (is_null($options)) {
58 $this->dbHost =
'localhost';
60 $this->dbUser = $USER;
61 $this->dbPassword = $PASSWORD;
68 if(is_resource($this->_pg_conn)) {
78 public function get_pg_ERROR() {
79 return($this->pg_ERROR);
92 public function connect($options = NULL) {
93 if (is_resource($this->_pg_conn)) {
94 return ($this->_pg_conn);
98 return ($this->_pg_conn);
112 private function _docon($options = NULL) {
114 $dbname =
'fossology';
116 if (is_null($options)) {
117 $this->_pg_conn = pg_pconnect(
"host=$this->dbHost dbname=$dbname " .
118 "user=$this->dbUser password=$this->dbPassword");
121 $this->_pg_conn = pg_pconnect(str_replace(
";",
" ", $options));
123 $res = pg_last_error($this->_pg_conn);
125 if(is_null($this->_pg_conn)) {
126 $this->pg_Error = TRUE;
127 print
"DB: could not connect to the db, connection is NULL\n";
131 if($this->_pg_conn === FALSE) {
132 $this->pg_Error = TRUE;
133 print
"DB: could not connect to the db, connect is FALSE\n";
136 if (!isset ($this->_pg_conn)) {
161 $uid = posix_getuid();
162 $uidInfo = posix_getpwuid($uid);
163 $this->pg_rows = array ();
164 if (!$this->_pg_conn) {
165 return ($this->pg_rows);
168 return ($this->pg_rows);
171 @ $result = pg_query($this->_pg_conn, $Sql);
175 $this->pg_rows = pg_affected_rows($result);
178 if (!isset ($result)) {
179 print
"DB-Query: result not set!\n";
182 @ $rows = pg_fetch_all($result);
184 if (!is_array($rows)) {
188 @ pg_free_result($result);
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.