--- a
+++ b/koha2libki/trunk/koha2libki_regenerate_libki_db.php
@@ -0,0 +1,31 @@
+#!/usr/bin/php
+<?php
+$startingUnits = "30";
+
+$libki = parse_ini_file("/etc/koha-tools/libki.ini");
+$koha = parse_ini_file("/etc/koha-tools/koha-tools.ini");
+
+## Open the Koha MySQL database
+$mysql_handle = mysql_connect( $koha["host"], $koha["username"], $koha["password"] );
+mysql_select_db( $koha["database"] ) or die( "Unable to open Koha database." );
+
+## Open the LibKi PostgreSQL database
+$pg_handle = pg_pconnect( "host=" . $libki["host"] . " dbname=" . $libki["database"] . " user=" . $libki["username"] . " password=" . $libki["password"] );
+if ( ! $pg_handle ) { echo "Connection attempt failed."; }
+
+$query = "DELETE FROM login WHERE admin = FALSE"
+
+$query = "SELECT cardnumber, password FROM borrowers";
+$results = mysql_query( $query );
+
+while ( $result = mysql_fetch_assoc( $results ) ) {
+  $cardnumber = $result['cardnumber'];
+  $password = $result['password'];
+  
+  $query = "INSERT INTO login ( username, units, status, password ) VALUES ( '$cardnumber', '$startingUnits', 'Logged out', '$password' )";
+  pg_query( $pg_handle, $query ) or die( "Update Failed\n" );;
+}
+
+pg_close($pg_handle);
+                           
+?>