Skip to content

phpfacile/geocoding-db-zend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPFacile! Geocoding-db-zend

This service store in database (using zend-db) a location retrieved using phpfacile/geocoding (Cf. https://github.com/phpfacile/geocoding).

Installation

At the root of your project type

composer require phpfacile/geocoding-db-zend

Or add "phpfacile/geocoding-db-zend": "^1.0" to the "require" part of your composer.json file

"require": {
    "phpfacile/geocoding-db-zend": "^1.0"
}

Usage

Step 1 : Adapter instanciation

Instanciate a Zend Adapter to allow a connexion to a database.

Example with SQLite (for test purpose only)

$config = [
    'driver' => 'Pdo_Sqlite',
    'database' => 'my_database.sqlite',
];
$adapter = new Zend\Db\Adapter\Adapter($config);

Example with MySQL

$config = [
    'driver' => 'Pdo_Mysql',
    'host' => 'localhost'
    'dbname' => 'my_database',
    'user' => 'my_username',
    'password' => 'my_password',
];
$adapter = new Zend\Db\Adapter\Adapter($config);

Step 2 : LocationService instanciation

use PHPFacile\Geocoding\Db\Service\LocationService;

$locationService = new LocationService($adapter);

Step 3 : Store a location and/or get it's id if already in database

Assuming you've got a $location StdClass retrieved from a previous phpfacile/geocoding query:

$id = $locationService->getIdOfStdClassLocationAfterInsertIfNeeded($location)

About

Service mainly aimed at storing in database (using zend-db) a location retrieved thanks to phpfacile/geocoding

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages