use DBI;
use Getopt::Std;
-###################################################
-# GLOBALS
-$dbname = "phpgroupware";
-$dbhost = "192.168.0.2"; # This can be an IP address or name
-$dbport = 3306;
-$dbuser = "phpgroupware"; # This may require an additional '\@localhost'
-$dbpass = "phpgroupware";
-###################################################
+$mydir = `cd \$(dirname $0) 2>/dev/null; pwd`; chomp($mydir);
+unshift @INC,("$mydir/../setup");
+if( -f "$mydir/../setup/db_config.local") { require "db_config.local"; }
+else { require "db_config"; }
%hometeaching_data = ();
%membership_data = ();
#| Field | Type | Null | Key | Default | Extra |
#+-------------+------------------+------+-----+---------+----------------+
#| elder | int(16) unsigned | | PRI | NULL | auto_increment |
+#| indiv_id | int(16) unsigned | | | NULL | |
#| name | varchar(60) | YES | | NULL | |
#| phone | varchar(12) | YES | | NULL | |
+#| email | varchar(120) | YES | | NULL | |
#| ppi_pri | int(10) unsigned | YES | | 1 | |
#| ppi_notes | varchar(128) | YES | | NULL | |
#| int_pri | int(10) unsigned | YES | | 1 | |
if($rows == 0) {
# No existing records found for this elder, make a new entry
print " Adding new Elder: $elder_name\n";
- $sth = $dbh->prepare("insert into eq_elder values (NULL,'$elder_name','$phone','1','','1','',$attending,1)");
+ $sth = $dbh->prepare("insert into eq_elder values (NULL,'$id','$elder_name','$phone','','1','','1','',$attending,1)");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
} elsif($rows == 1) {
# An existing record was found for this elder, update it
$sth->execute or die "-E- DB error: $DBI::errstr\n";
$sth = $dbh->prepare("update eq_elder set attending='$attending' where name='$elder_name'");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
+ $sth = $dbh->prepare("update eq_elder set indiv_id='$id' where name='$elder_name'");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
} else {
# More than one record was found. Error! This shouldn't happen.
print " -E- More than one record found ($rows) for Elder: $elder_name\n";
###################################################
# Open a connection to the database
-$dbh=DBI->connect("dbi:mysql:dbname=$dbname;host=$dbhost;port=$dbport",$dbuser,$dbpass,{
+$dbh=DBI->connect("dbi:mysql:dbname=$dbname:host=$dbhost:port=$dbport",$dbuser,$dbpass,{
AutoCommit=>0,
PrintError=>0}) or print "Connect Failure:".$DBI::errstr."\n" and exit 2;