Last active
January 30, 2019 12:43
-
-
Save otuoma/177ab5f407d18cb06c270ee7b34289c5 to your computer and use it in GitHub Desktop.
This codeigniter script helped me to migrate koha's biblioitems.marcxml into biblio_metadata table after upgrading. To use it, set up codeigniter and configure it to connect to the old koha database and the new database. Then include this class in controllers. Run it via the commandline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Migrate extends CI_Controller { | |
public function __construct(){ | |
parent::__construct(); | |
$db = &get_instance(); | |
$this->db = $db->load->database('default', TRUE); | |
$old_koha = &get_instance(); | |
$this->old_koha = $old_koha->load->database('old_koha', TRUE); | |
} | |
public function migrate_marcxml(){ | |
$q = $this->old_koha->query("SELECT biblionumber, timestamp, marcxml FROM biblioitems"); | |
$success = 0; | |
$fails = 0; | |
foreach ($q->result() as $row){ | |
echo "\nMigrating biblio ".$row->biblionumber; | |
if (!$row->marcxml){$marcxml = "";}else{$marcxml = $row->marcxml;} | |
$data = array( | |
'biblionumber'=>$row->biblionumber, | |
'metadata'=>$marcxml, | |
'timestamp'=>$row->timestamp, | |
'format'=>'marcxml', | |
'marcflavour'=>'MARC21' | |
); | |
$sql = "INSERT IGNORE INTO biblio_metadata "; | |
$sql .= "(biblionumber, metadata, timestamp, format, marcflavour) "; | |
$sql .= "VALUES ('$row->biblionumber', ".$this->db->escape($row->marcxml).", '$row->timestamp', 'marcxml', 'MARC21');"; | |
$this->db->query($sql); | |
if($this->db->affected_rows() > 0){ | |
echo " Success\n"; | |
$success = $success + 1; | |
}else{ | |
echo " Failed\n"; | |
$fails = $fails + 1; | |
} | |
} //end foreach | |
echo "=======END=============\n"; | |
echo "Total records : ".$q->num_rows()."\n";; | |
echo "Success : ".$success." records\n"; | |
echo "Failed : ".$fails." records\n"; | |
} //end public function | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
View the issue in detail here http://koha.1045719.n5.nabble.com/Error-retrieving-biblio-in-rebuild-zebra-pl-line-680-td6010548.html