X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=blobdiff_plain;f=bin%2Fmerge_eq_ppi_eq_interview_tables;fp=bin%2Fmerge_eq_ppi_eq_interview_tables;h=c53ed4fc58b09535cc1fd843133d74ecbe79c2c3;hb=9dc519979d37f94ab0bec341d3508819cd3b68d3;hp=0000000000000000000000000000000000000000;hpb=af61eec323981d19d4d95a90aa26fa761e904194;p=eq%2F.git diff --git a/bin/merge_eq_ppi_eq_interview_tables b/bin/merge_eq_ppi_eq_interview_tables new file mode 100755 index 0000000..c53ed4f --- /dev/null +++ b/bin/merge_eq_ppi_eq_interview_tables @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +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"; +################################################### + +################################################### +# Connect to the database +$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; +################################################### + +# Add a new 'aaronic' column to the eq_ppi table +$sth = $dbh->prepare("ALTER TABLE `eq_ppi` ADD `aaronic` INT( 16 ) NOT NULL DEFAULT '0' AFTER `elder`"); +$sth->execute or die "-E- DB error: $DBI::errstr\n"; + +# Parse the data out of the eq_interview table and add them to the eq_ppi table +$sth = $dbh->prepare("select * from eq_interview"); +$sth->execute or die "-E- DB error: $DBI::errstr\n"; +while($row = $sth->fetchrow_hashref) { + $interviewer = $row->{interviewer}; + $elder = $row->{elder}; + $aaronic = $row->{aaronic}; + $date = $row->{date}; + $notes = $row->{notes}; + $notes =~ s/\'/\\\'/g; + $eqpresppi = 0; + #print "$interviewer $elder $aaronic $date $eqpresppi $notes\n"; + $sth2 = $dbh->prepare("insert into eq_ppi values (NULL,'$interviewer','$elder','$aaronic','$date','$notes','$eqpresppi')"); + $sth2->execute or die "-E- DB error: $DBI::errstr\n"; +} + +print "\n-> Succesfully imported all eq_interview table entries into eq_ppi table...\n"; +print "-> You may drop the eq_interview table once you know all your data was transferred to the eq_ppi table correctly..\n"; + +################################################### +# Disconnect from the database +$dbh->disconnect(); +################################################### + +