- <?php
-
- /*
- * sptpl_db_pgsql.php
- *
- * Postgresql access module
- *
- * require: sptpl_db.php
- *
- * Author: Igor Támara igor@tamarapatino.org
- *
- * License: The same of SpTpl
- *
- */
- class db_pgsql extends CDB {
-
- function db_pgsql()
- {
- }
-
- function DbOpen($DBSystem,$DBUser,$DBPasswd,$DBName)
- {
- if ($DBSystem!=null) {
- $a="host=".$DBSystem;
- }
- if ($DBUser!=null) {
- $a.=" user=".$DBUser;
- }
- if ($DBPasswd!=null) {
- $a.=" password=".$DBPasswd;
- }
- if ($DBName!=null) {
- $a.=" dbname=$DBName";
- }
- if(($this->DbConn=pg_connect($a))===FALSE)
- {
- // Error connectig to the database
- trigger_error("Error during connection to the server ".$DBSystem,E_USER_ERROR);
- }
- }
-
- function DbExecSql($sql)
- {
- if(($this->DbResult=pg_query($this->DbConn,$sql))===FALSE)
- {
- // Error during select
- trigger_error("Error in sql statement. Sql string: ".$sql." Error:". pg_lasterror());
- }
- return(TRUE);
- }
-
- function DbGetValue()
- {
- return(pg_fetch_array($this->DbResult));
- }
-
- function DbClose()
- {
- pg_close($this->DbConn);
- }
-
- }
- ?>