From e483304ac8170869ea9c0300b2169aae395a39c5 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Wed, 19 Jun 2013 15:31:09 +0200 Subject: [PATCH] add sps service --- geoapi/api/Api.php | 14 +++++++------ geoapi/api/SpsApi.php | 17 +++++++++++----- geoapi/database/HelloApiSQLManager.php | 4 ++-- geoapi/database/SpsSqlManager.php | 20 ++++++++++++++++--- .../{SQLManager.php => SqlManager.php} | 3 ++- geoapi/service/sps/.htaccess | 2 ++ geoapi/service/sps/index.php | 15 ++++++++++++++ 7 files changed, 58 insertions(+), 17 deletions(-) rename geoapi/database/{SQLManager.php => SqlManager.php} (96%) create mode 100644 geoapi/service/sps/.htaccess create mode 100644 geoapi/service/sps/index.php diff --git a/geoapi/api/Api.php b/geoapi/api/Api.php index fd49962..ab8bb63 100644 --- a/geoapi/api/Api.php +++ b/geoapi/api/Api.php @@ -1,7 +1,7 @@ sqlManager) { - echo "bla"; - $this->sqlManager = new SQLManager(); - } + $this->connect(); parent::__construct(); } public function __destruct() { + $this->close(); $this->sqlManager = null; //parent::__destruct(); } - public function connect() { + private function connect() { $this->sqlManager->connect(); } + private function close() { + $this->sqlManager->close(); + } + } ?> diff --git a/geoapi/api/SpsApi.php b/geoapi/api/SpsApi.php index 11c9701..3e7e431 100644 --- a/geoapi/api/SpsApi.php +++ b/geoapi/api/SpsApi.php @@ -1,7 +1,8 @@ sqlManager = new SpsSqlManager(); parent::__construct(); } - + public function __destruct() { parent::__destruct(); } + + public function sendSpsQuery($queryArgs = array()) { + return $this->sqlManager->sendSpsQuery($queryArgs); + } + } ?> diff --git a/geoapi/database/HelloApiSQLManager.php b/geoapi/database/HelloApiSQLManager.php index 27914e3..b0333d8 100644 --- a/geoapi/database/HelloApiSQLManager.php +++ b/geoapi/database/HelloApiSQLManager.php @@ -1,13 +1,13 @@ query("SELECT * FROM sps Where alias = \"$alias\""); + } } ?> diff --git a/geoapi/database/SQLManager.php b/geoapi/database/SqlManager.php similarity index 96% rename from geoapi/database/SQLManager.php rename to geoapi/database/SqlManager.php index 6cafa0d..0e9115b 100644 --- a/geoapi/database/SQLManager.php +++ b/geoapi/database/SqlManager.php @@ -7,7 +7,7 @@ include_once "../../global.inc.php"; * * @author stubbfel */ -class SQLManager { +abstract class SqlManager { private $serverAddress; private $userName; @@ -39,6 +39,7 @@ class SQLManager { public function close() { if ($this->link) { mysql_close($this->link); + $this->link =null; } } diff --git a/geoapi/service/sps/.htaccess b/geoapi/service/sps/.htaccess new file mode 100644 index 0000000..450c0d1 --- /dev/null +++ b/geoapi/service/sps/.htaccess @@ -0,0 +1,2 @@ +RewriteEngine on +RewriteRule ^ index.php [QSA,L] \ No newline at end of file diff --git a/geoapi/service/sps/index.php b/geoapi/service/sps/index.php new file mode 100644 index 0000000..5dbe497 --- /dev/null +++ b/geoapi/service/sps/index.php @@ -0,0 +1,15 @@ +get('/alias/:alias', function ($alias) use ($app) { + $args =array(); + $args["alias"] = $alias; + print_r($app->sendSpsQuery($args)); +}); + +$app->run(); +?>