当前位置: 首页>>代码示例>>PHP>>正文


PHP SQLite3::loadExtension方法代码示例

本文整理汇总了PHP中SQLite3::loadExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLite3::loadExtension方法的具体用法?PHP SQLite3::loadExtension怎么用?PHP SQLite3::loadExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLite3的用法示例。


在下文中一共展示了SQLite3::loadExtension方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * SpatialiteNativeDriver constructor.
  *
  * @param $filename
  */
 public function __construct($filename)
 {
     $isNewDatabase = !file_exists($filename);
     $this->db = new \SQLite3($filename);
     $this->db->loadExtension('mod_spatialite.so');
     if ($isNewDatabase) {
         $this->initDbFile();
     }
 }
开发者ID:eslider,项目名称:spatialite,代码行数:14,代码来源:SpatialiteNativeDriver.php

示例2: __construct

 public function __construct($filename, $flags = null, $encryptionKey = null, $busyTimeout = null, array $userDefinedFunctions = array(), array $userDefinedExtensions = array())
 {
     if (null === $flags) {
         $flags = \SQLITE3_OPEN_READWRITE | \SQLITE3_OPEN_CREATE;
     }
     $this->_conn = new SQLite3($filename, $flags, $encryptionKey);
     if (null !== $busyTimeout) {
         $this->_conn->busyTimeout($busyTimeout);
     } else {
         $this->_conn->busyTimeout(60000);
     }
     foreach ($userDefinedFunctions as $fn => $data) {
         $this->_conn->createFunction($fn, $data['callback'], $data['numArgs']);
     }
     foreach ($userDefinedExtensions as $extension) {
         $this->_conn->loadExtension($extension);
     }
 }
开发者ID:jsor,项目名称:dbal-sqlite3,代码行数:18,代码来源:Connection.php

示例3: getWidthRiver

function getWidthRiver($coordinates)
{
    $units = json_decode($coordinates);
    $unit_1 = $units[0][0] . ',' . $units[0][1];
    $unit_2 = $units[1][0] . ',' . $units[1][1];
    if (file_exists('poland.sqlite')) {
        $db = new SQLite3("poland.sqlite");
    }
    if (file_exists('mod_spatialite.so.7.1.0')) {
        $db->loadExtension('mod_spatialite.so.7.1.0');
    }
    $db->exec("SELECT InitSpatialMetadata()");
    # Запрос на поиск пересечения линии между юнитами и рек.
    # Переменная out выходной словарь с данными
    $rs = $db->query("SELECT id, name, sub_type, AsGeoJSON(Geometry) AS json FROM ln_waterway WHERE Crosses(MakeLine(MakePoint({$unit_1}), MakePoint({$unit_2})), Geometry)");
    # Если тип найденной реки "riverbank", для нее находим ширину реки. Иначе width = -1;
    # В выдачу добавлены точки пересечения прямой между юнитами с рекой, т.е. по сути точки берега реки, через который,
    # проходит бой юнитов.
    # В переменной $row[0] находятся точки персечения
    while ($river = $rs->fetchArray()) {
        if ($river['sub_type'] == 'riverbank') {
            $points = $db->query("SELECT AsGeoJSON(Intersection(MakeLine(MakePoint(" . $unit_1 . "), MakePoint(" . $unit_2 . ")), GeomFromGeoJSON('" . $river['json'] . "')))");
            $row = $points->fetchArray();
            $jdecode = json_decode($row[0]);
            $i = 0;
            foreach ($jdecode->coordinates as $value) {
                $lng[$i] = $value[0];
                $lat[$i] = $value[1];
                $i++;
            }
            $width = widthRiver($lat[0], $lng[0], $lat[1], $lng[1]);
            $out[$river['name']] = ['id' => $river['id'], 'width' => $width, 'x_cross1' => $lng[0], 'y_cross1' => $lat[0], 'x_cross2' => $lng[1], 'y_cross2' => $lat[1]];
        } else {
            if (!$out[$river['name']]) {
                $out[$river['name']] = ['id' => $river['id'], 'width' => -1];
            }
        }
    }
    $jencode = json_encode($out);
    return $jencode;
}
开发者ID:kuzovkov,项目名称:geoservice_python,代码行数:41,代码来源:widthRiver.php

示例4: _connect

 protected function _connect()
 {
     $db = $this->profile['database'];
     if (preg_match('/^(app|lib|var|temp|www)\\:/', $db)) {
         $path = jFile::parseJelixPath($db);
     } else {
         if ($db[0] == '/' || preg_match('!^[a-z]\\:(\\\\|/)[a-z]!i', $db)) {
             if (file_exists($db) || file_exists(dirname($db))) {
                 $path = $db;
             } else {
                 throw new Exception('sqlite3 connector: unknown database path scheme');
             }
         } else {
             $path = jApp::varPath('db/sqlite3/' . $db);
         }
     }
     $sqlite = new SQLite3($path);
     // Load extensions if needed
     if (isset($this->profile['extensions'])) {
         $list = preg_split('/ *, */', $this->profile['extensions']);
         foreach ($list as $ext) {
             try {
                 $sqlite->loadExtension($ext);
             } catch (Exception $e) {
                 throw new Exception('sqlite3 connector: error while loading sqlite extension ' . $ext);
             }
         }
     }
     // set timeout
     if (isset($this->profile['busytimeout'])) {
         $timeout = intval($this->profile['busytimeout']);
         if ($timeout) {
             $sqlite->busyTimeout($timeout);
         }
     }
     return $sqlite;
 }
开发者ID:CREASIG,项目名称:lizmap-web-client,代码行数:37,代码来源:sqlite3.dbconnection.php

示例5: getUpdatedConfig


//.........这里部分代码省略.........
                     continue;
                 }
                 $cLabelItem = $cLabelItem[0];
                 if ((string) $cLabelItem['id'] == '') {
                     continue;
                 }
                 $printTemplate['labels'][] = array('id' => (string) $cLabelItem['id'], 'htmlState' => (int) $cLabel['htmlState'], 'text' => (string) $cLabel['labelText']);
             }
             $printTemplates[] = $printTemplate;
         }
         // set printTemplates in config
         $configJson->printTemplates = $printTemplates;
     }
     // Update locate by layer with vecctorjoins
     if (property_exists($configJson, 'locateByLayer')) {
         // collect layerIds
         $locateLayerIds = array();
         foreach ($configJson->locateByLayer as $k => $v) {
             $locateLayerIds[] = $v->layerId;
         }
         // update locateByLayer with alias and filter information
         foreach ($configJson->locateByLayer as $k => $v) {
             $xmlLayer = $this->getXmlLayer($v->layerId);
             $xmlLayerZero = $xmlLayer[0];
             // aliases
             $alias = $xmlLayerZero->xpath("aliases/alias[@field='" . $v->fieldName . "']");
             if (count($alias) != 0) {
                 $alias = $alias[0];
                 $v->fieldAlias = (string) $alias['name'];
                 $configJson->{$k} = $v;
             }
             if (property_exists($v, 'filterFieldName')) {
                 $alias = $xmlLayerZero->xpath("aliases/alias[@field='" . $v->filterFieldName . "']");
                 if (count($alias) != 0) {
                     $alias = $alias[0];
                     $v->filterFieldAlias = (string) $alias['name'];
                     $configJson->{$k} = $v;
                 }
             }
             // vectorjoins
             $vectorjoins = $xmlLayerZero->xpath('vectorjoins/join');
             if (count($vectorjoins) != 0) {
                 if (!property_exists($v, 'vectorjoins')) {
                     $v->vectorjoins = array();
                 }
                 foreach ($vectorjoins as $vectorjoin) {
                     $joinLayerId = (string) $vectorjoin['joinLayerId'];
                     if (in_array($joinLayerId, $locateLayerIds)) {
                         $v->vectorjoins[] = (object) array("joinFieldName" => (string) $vectorjoin['joinFieldName'], "targetFieldName" => (string) $vectorjoin['targetFieldName'], "joinLayerId" => (string) $vectorjoin['joinLayerId']);
                     }
                 }
                 $configJson->{$k} = $v;
             }
         }
     }
     // Remove FTP remote directory
     if (property_exists($configJson->options, 'remoteDir')) {
         unset($configJson->options->remoteDir);
     }
     // Remove editionLayers from config if no right to access this tool
     // Or if no ability to load spatialite extension
     if (property_exists($configJson, 'editionLayers')) {
         if (jAcl2::check('lizmap.tools.edition.use', $this->repository->getKey())) {
             $spatial = false;
             if (class_exists('SQLite3')) {
                 try {
                     $db = new SQLite3(':memory:');
                     $spatial = $db->loadExtension('libspatialite.so');
                     # loading SpatiaLite as an extension
                 } catch (Exception $e) {
                     $spatial = False;
                 }
             }
             if (!$spatial) {
                 foreach ($configJson->editionLayers as $key => $obj) {
                     $layerXml = $this->getXmlLayer($obj->layerId);
                     $layerXmlZero = $layerXml[0];
                     $provider = $layerXmlZero->xpath('provider');
                     $provider = (string) $provider[0];
                     if ($provider == 'spatialite') {
                         unset($configJson->editionLayers->{$key});
                     }
                 }
             }
         } else {
             unset($configJson->editionLayers);
         }
     }
     // Add export layer right
     if (jAcl2::check('lizmap.tools.layer.export', $this->repository->getKey())) {
         $configJson->options->exportLayers = 'True';
     }
     // Update config with layer relations
     $relations = $this->getRelations();
     if ($relations) {
         $configJson->relations = $relations;
     }
     $configRead = json_encode($configJson);
     return $configRead;
 }
开发者ID:vincent-petale,项目名称:lizmap-web-client,代码行数:101,代码来源:lizmapProject.class.php

示例6: Exception

             $insert_final->bindValue('region', $p->region);
             $insert_final->bindValue('realm', $p->realm);
             $insert_final->bindValue('geom', $endpoly);
             $insert_final->execute();
         }
     }
     break;
 case 'exportsql':
     if (empty($args->command->options['spatialite'])) {
         throw new Exception("Must specify spatialite DB");
     }
     if (empty($args->command->options['table'])) {
         throw new Exception("Must specify Table Name");
     }
     $sdb = new SQLite3($args->command->options['spatialite']);
     $sdb->loadExtension($config->spatialite);
     $allzones = $sdb->prepare(sprintf("SELECT zone_id FROM %s" . (empty($args->command->options['filter']) ? "" : " WHERE %s"), $args->command->options['table'], $args->command->options['filter']));
     $getFullPolygon = $sdb->prepare(sprintf("SELECT AsText(polygon) FROM %s WHERE zone_id = :zone", $args->command->options['table']));
     $res = $allzones->execute();
     $zones = array();
     $fp = fopen($args->command->options['outputfile'], "w");
     fputs($fp, "DROP TABLE IF EXISTS zonetable;\n");
     fputs($fp, "CREATE TABLE zonetable (zone_id INT UNSIGNED NOT NULL PRIMARY KEY, poly GEOMETRY NOT NULL);\n");
     while ($row = $res->fetchArray(SQLITE3_NUM)) {
         $getFullPolygon->bindValue('zone', $row[0], SQLITE3_INTEGER);
         $res2 = $getFullPolygon->execute();
         $poly = $res2->fetchArray(SQLITE3_NUM);
         $res2->finalize();
         fprintf($fp, "INSERT INTO zonetable (zone_id, poly) VALUES (%d,GeomFromText(%s));\n", $row[0], $dbh->quote($poly[0]));
     }
     fclose($fp);
开发者ID:Anpu,项目名称:INQ-Calculators,代码行数:31,代码来源:zonemap.php

示例7: openSQLiteDb

function openSQLiteDb($dbname_faims)
{
    $dbfaims = new SQLite3($dbname_faims);
    //':memory:');
    if (!$dbfaims) {
        print "<div style='color:red; font-weight:bold;padding:10px'>Cannot open the database</div>";
        return false;
    }
    # reporting some version info
    $rs = $dbfaims->query('SELECT sqlite_version()');
    while ($row = $rs->fetchArray()) {
        print "<h3>Server running: SQLite version: {$row['0']}</h3>&nbsp;";
    }
    $use_Spatialite = true;
    if ($use_Spatialite) {
        //TEMP
        # loading SpatiaLite as an extension
        $dbfaims->loadExtension('libspatialite.so');
        # enabling Spatial Metadata
        # using v.2.4.0 this automatically initializes SPATIAL_REF_SYS
        # and GEOMETRY_COLUMNS
        $dbfaims->exec("SELECT InitSpatialMetadata()");
        $rs = $dbfaims->query('SELECT spatialite_version()');
        if ($rs) {
            while ($row = $rs->fetchArray()) {
                print "<h3>Server running: SpatiaLite version: {$row['0']}</h3>";
            }
        } else {
            print "<div style='color:red; font-weight:bold;padding:10px'>\n                        Sorry, we are unable to sync the Heurist database with the FAIMS SQLite database\n                        <br/>as we cannot detect SpatiaLite (spatial functions for SQLite).\n                        <br/>Please ask your sysadmin to SpatiaLite on the server.</div>";
            return false;
        }
    }
    //use spatialite
    return $dbfaims;
}
开发者ID:HeuristNetwork,项目名称:heurist,代码行数:35,代码来源:syncFAIMS.php

示例8: catch

<?php

$db = new SQLite3(':memory:');
try {
    $db->loadExtension("");
} catch (Extension $ex) {
    var_dump($ex->getMessage());
}
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:sqlite3_34_load_extension_ext_dir.php

示例9:

<?php

$db = new SQLite3(':memory:');
var_dump($db->loadExtension(array()));
echo "Done\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:sqlite3_loadextension_with_wrong_param.php

示例10: readEditionLayers

 protected function readEditionLayers($xml, $cfg)
 {
     $editionLayers = array();
     if (property_exists($cfg, 'editionLayers')) {
         // Add data into editionLayers from configuration
         $editionLayers = $cfg->editionLayers;
         // Check ability to load spatialite extension
         // And remove ONLY spatialite layers if no extension found
         $spatial = false;
         if (class_exists('SQLite3')) {
             // Try with libspatialite
             try {
                 $db = new SQLite3(':memory:');
                 $spatial = @$db->loadExtension('libspatialite.so');
                 # loading SpatiaLite as an extension
             } catch (Exception $e) {
                 $spatial = False;
             }
             // Try with mod_spatialite
             if (!$spatial) {
                 try {
                     $db = new SQLite3(':memory:');
                     $spatial = @$db->loadExtension('mod_spatialite.so');
                     # loading SpatiaLite as an extension
                 } catch (Exception $e) {
                     //jLog::log($e->getMessage(), 'error');
                     $spatial = False;
                 }
             }
         }
         if (!$spatial) {
             jLog::log('Spatialite is not available', 'error');
             foreach ($editionLayers as $key => $obj) {
                 $layerXml = $this->getXmlLayer2($xml, $obj->layerId);
                 $layerXmlZero = $layerXml[0];
                 $provider = $layerXmlZero->xpath('provider');
                 $provider = (string) $provider[0];
                 if ($provider == 'spatialite') {
                     unset($editionLayers->{$key});
                 }
             }
         }
     }
     return $editionLayers;
 }
开发者ID:laurentj,项目名称:lizmap-web-client,代码行数:45,代码来源:lizmapProject.class.php


注:本文中的SQLite3::loadExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。