$cli->error("Error: couldn't connect to database '" . $db->DB . "'"); $cli->error(' for mysql try: '); $cli->error(' mysql -e "create database ' . $db->DB . ';"'); $cli->error(' mysql tmp < kernel/sql/mysql/kernel_schema.sql'); $cli->error(' or use --help for more info'); $script->shutdown(1); } } $cli->output("Using database '" . $cli->terminalStyle('red') . $db->DB . $cli->terminalStyle('normal') . "'"); $xml = simplexml_load_file($url); if ($xml === false) { $cli->error("Error retrieving '{$url}'"); $script->shutdown(1); } // Clean up all tables to add everything from the start. eZISBNGroup::cleanAll(); eZISBNGroupRange::cleanAll(); eZISBNRegistrantRange::cleanAll(); // Get registration groups. $registrationGroups = $xml->xpath('RegistrationGroups/Group'); foreach ($registrationGroups as $group) { // Prefix is always 978 or 979 followed by an hyphen (-) and up to 5 digits // Explode it in order to get the group number $prefixArray = explode('-', $group->Prefix); $groupNumber = $prefixArray[1]; $description = $group->Agency; // name $isbnGroup = eZISBNGroup::create($groupNumber, $description); $isbnGroup->store(); $isbnGroupID = $isbnGroup->attribute('id'); // look for the rules
function cleanDBDataBeforeImport() { eZISBNGroup::cleanAll(); eZISBNGroupRange::cleanAll(); eZISBNRegistrantRange::cleanAll(); return true; }