an argument to the function copy_db_class.
Fixed the PHP member function db::db_connect(). The Postgres connection
string is now passed as an argument to that function.
Gnucomo-0.0.3: December 6th 2002
$Log: gcm_daemon.php,v $
Gnucomo-0.0.3: December 6th 2002
$Log: gcm_daemon.php,v $
- Revision 1.9 2003-02-21 08:37:59 arjen
+ Revision 1.10 2003-03-29 08:33:58 arjen
+ In phpclasses/db.class.php: Added the database connection string as
+ an argument to the function copy_db_class.
+ Fixed the PHP member function db::db_connect(). The Postgres connection
+ string is now passed as an argument to that function.
+
+ Revision 1.9 2003/02/21 08:37:59 arjen
Added new table to the database: log_adv_daemon_email.
*/
Added new table to the database: log_adv_daemon_email.
*/
-// $Id: gcm_daemon.php,v 1.9 2003-02-21 08:37:59 arjen Exp $
+// $Id: gcm_daemon.php,v 1.10 2003-03-29 08:33:58 arjen Exp $
ini_set('include_path', '.:./classes:../phpclasses');
ini_set('include_path', '.:./classes:../phpclasses');
$project_name = "gnucomo"; //name of the entire project
$app_name = "gcm_daemon"; //name of the application running
$developrelease = "TRUE"; //Indicates if special debug settings are needed
$project_name = "gnucomo"; //name of the entire project
$app_name = "gcm_daemon"; //name of the application running
$developrelease = "TRUE"; //Indicates if special debug settings are needed
-$db_version = 32; //The db_version indicates what the level of
+$db_version = 36; //The db_version indicates what the level of
//the database should be. If the database is
//old an update will be generated.
$gcmd_version = 3; //This value indicates the active version of the gcm_daemon,
//the database should be. If the database is
//old an update will be generated.
$gcmd_version = 3; //This value indicates the active version of the gcm_daemon,
// Read the database settings //
$class_settings = new gnucomo_config();
$class_settings->read($project_name);
// Read the database settings //
$class_settings = new gnucomo_config();
$class_settings->read($project_name);
-$class_settings->database();
//Open an connection to the database
$dbms_type = $class_settings->find_parameter("database", "type");
//Open an connection to the database
$dbms_type = $class_settings->find_parameter("database", "type");
$dbms->db_name = $dbms_name;
$dbms->db_user = $dbms_user;
$dbms->db_password = $dbms_password;
$dbms->db_name = $dbms_name;
$dbms->db_user = $dbms_user;
$dbms->db_password = $dbms_password;
+$dbms->db_connect($class_settings->database());
if ($dbms->have_db_connection() == "FALSE") {
exit ("Database connection failed.");
} else {
//The database connection has been made.
if ($dbms->have_db_connection() == "FALSE") {
exit ("Database connection failed.");
} else {
//The database connection has been made.
- $dbms_working = copy_db_class($dbms);
+ $dbms_working = copy_db_class($dbms, $class_settings->database());
}
//Verify if the database is up-to-date by checking the versionnumber
}
//Verify if the database is up-to-date by checking the versionnumber
*/
global $dbms;
global $dbms_working;
*/
global $dbms;
global $dbms_working;
+ global $class_settings;
//Find records in log that still have to be processed.
//Find records in log that still have to be processed.
$dbms->query($local_sql);
//Update the log-statistics in the object-table
$dbms->query($local_sql);
//Update the log-statistics in the object-table
- $local_statistics_db = copy_db_class($dbms);
- $local_findobject_db = copy_db_class($dbms);
+ $local_statistics_db = copy_db_class($dbms, $class_settings->database());
+ $local_findobject_db = copy_db_class($dbms, $class_settings->database());
//Make totals
$local_upper_row = $dbms->num_rows() + $last_log + 1;
//Make totals
$local_upper_row = $dbms->num_rows() + $last_log + 1;
if ($dbms->num_rows() > 0) {
//Create a database connection for changes in the database.
if ($dbms->num_rows() > 0) {
//Create a database connection for changes in the database.
- $dbms_changes = copy_db_class($dbms);
+ $dbms_changes = copy_db_class($dbms, $class_settings->database());
if ($dbms_changes->have_db_connection() == 'TRUE') {
$local_sql = 0 ;
if ($dbms_changes->have_db_connection() == 'TRUE') {
$local_sql = 0 ;
+ global $dbms, $class_settings;
//Find records in log that still have to be processed.
$local_sql = "SELECT setting_value FROM db_value WHERE setting = 'last_notification'";
$dbms->query($local_sql);
//Find records in log that still have to be processed.
$local_sql = "SELECT setting_value FROM db_value WHERE setting = 'last_notification'";
$dbms->query($local_sql);
- $local_dbms = copy_db_class($dbms);
+ $local_dbms = copy_db_class($dbms, $class_settings->database());
//Determine the last notification
if ($dbms->fetch_row() == "TRUE") {
//Determine the last notification
if ($dbms->fetch_row() == "TRUE") {
require_once ("db.".$local_db_type.".php");
}
require_once ("db.".$local_db_type.".php");
}
- function copy_db_class ($inp_class) {
+ function copy_db_class ($inp_class, $connection_string) {
/* This function takes a database class, sets the values for the connection,
* opens the connection and returns the new cloned class
* INPUT : inp_class - Typically a database class
/* This function takes a database class, sets the values for the connection,
* opens the connection and returns the new cloned class
* INPUT : inp_class - Typically a database class
$new_class->db_name = $inp_class->db_name;
$new_class->db_user = $inp_class->db_user;
$new_class->db_password = $inp_class->db_password;
$new_class->db_name = $inp_class->db_name;
$new_class->db_user = $inp_class->db_user;
$new_class->db_password = $inp_class->db_password;
- $new_class->db_connect();
+ $new_class->db_connect($connection_string);
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
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.
/* 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)
- $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");
syslog (LOG_INFO, "Failed to make a connection to Postgres");
die ("connection to Postgres failed\n");
syslog (LOG_INFO, "Connection to Postgres was made correctly");
}
}
syslog (LOG_INFO, "Connection to Postgres was made correctly");
}
}