[r548]: koha2libki / trunk / koha2libki_regenerate_libki_db.php  Maximize  Restore  History

Download this file

31 lines (22 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
?>