return 'ARRAY['.join(',', $a).']';
}
- public function getLastError()
- {
- // https://secure.php.net/manual/en/pdo.errorinfo.php
- return $this->connection->errorInfo();
- }
-
/**
* Check if a table exists in the database. Returns true if it does.
*
}
// Try accessing the C module, so we know early if something is wrong
- if (!checkModulePresence()) {
- fail('error loading nominatim.so module');
- }
+ checkModulePresence(); // raises exception on failure
if (!file_exists(CONST_ExtraDataPath.'/country_osm_grid.sql.gz')) {
echo 'Error: you need to download the country_osm_grid first:';
{
info('Create Functions');
- // Try accessing the C module, so we know eif something is wrong
- // update.php calls this function
- if (!checkModulePresence()) {
- fail('error loading nominatim.so module');
- }
+ // Try accessing the C module, so we know early if something is wrong
+ checkModulePresence(); // raises exception on failure
+
$this->createSqlFunctions();
}
function checkModulePresence()
{
- // Try accessing the C module, so we know early if something is wrong
- // and can simply error out.
+ // Try accessing the C module, so we know early if something is wrong.
+ // Raises Nominatim\DatabaseError on failure
+
$sModulePath = CONST_Database_Module_Path;
$sSQL = "CREATE FUNCTION nominatim_test_import_func(text) RETURNS text AS '";
$sSQL .= $sModulePath . "/nominatim.so', 'transliteration' LANGUAGE c IMMUTABLE STRICT";
$oDB = new \Nominatim\DB();
$oDB->connect();
-
- $bResult = true;
- try {
- $oDB->exec($sSQL);
- } catch (\Nominatim\DatabaseError $e) {
- echo "\nERROR: Failed to load nominatim module. Reason:\n";
- echo $oDB->getLastError()[2] . "\n\n";
- $bResult = false;
- }
-
- return $bResult;
+ $oDB->exec($sSQL, null, 'Database server failed to load '.$sModulePath.'/nominatim.so module');
}
}
// Try accessing the C module, so we know early if something is wrong
-if (!checkModulePresence()) {
- fail('error loading nominatim.so module');
-}
+checkModulePresence(); // raises exception on failure
if ($aCMDResult['import-data'] || $aCMDResult['all']) {
$bDidSomething = true;