In phpclasses/db.class.php: Added the database connection string as
[gnucomo.git] / src / phpclasses / db.postgres.php
index 0fc268c..e8e911c 100644 (file)
    var $db_row_number;    //The row-number that is currently active
    var $db_result_row;    //Array with in each element a field of the result
 
-   function db_connect () {
+   function db_connect ($connection_string)
+   {
     /* This function makes the connection to the database. It will look at the selected DBMS. 
      * It will detected if password or hostname is missing and leave that out of the string.
-     * INPUT: NONE (all defined in the class)
+     * INPUT: NONE (The database connection string)
      * OUTPUT: NONE
      */ 
-     $local_connection_string = '';
-     if ($this->db_host == '') {
-        $local_connection_string .= "host=$this->db_host ";
-     }
     
-     $local_connection_string = "dbname=$this->db_name user=$this->db_user ";
-
-     if ($this->db_password == '') {
-        $local_connection_string .= $this->db_password;
-     }
+       $this->db_connection = pg_pconnect($connection_string);
 
-       $this->db_connection = pg_pconnect($local_connection_string);
-       if ($this->have_db_connection() == FALSE) {
+       if ($this->have_db_connection() == FALSE)
+        {
           syslog (LOG_INFO, "Failed to make a connection to Postgres");
            die ("connection to Postgres failed\n");
-       } else {
+       }
+        else
+        {
           syslog (LOG_INFO, "Connection to Postgres was made correctly");
        }
    }