add sps service

This commit is contained in:
stubbfel
2013-06-19 15:31:09 +02:00
parent e71a7ce946
commit e483304ac8
7 changed files with 58 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
<?php
include_once "../../global.inc.php";
include_once PATH_DATABASE . "/SQLManager.php";
include_once PATH_DATABASE . "/SqlManager.php";
require_once PATH_3PARTY . "/Slim/Slim.php";
\Slim\Slim::registerAutoloader();
@@ -10,22 +10,24 @@ abstract class Api extends \Slim\Slim {
protected $sqlManager;
public function __construct() {
if (!$this->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();
}
}
?>

View File

@@ -1,7 +1,8 @@
<?php
include_once "../../global.inc.php";
require_once PATH_API."/Api.php";
include_once "../../global.inc.php";
include_once PATH_DATABASE . "/SpsSqlManager.php";
require_once PATH_API . "/Api.php";
/*
* To change this template, choose Tools | Templates
@@ -13,15 +14,21 @@ require_once PATH_API."/Api.php";
*
* @author stubbfel
*/
class SpsApi extends Api{
class SpsApi extends Api {
public function __construct() {
$this->sqlManager = new SpsSqlManager();
parent::__construct();
}
public function __destruct() {
parent::__destruct();
}
public function sendSpsQuery($queryArgs = array()) {
return $this->sqlManager->sendSpsQuery($queryArgs);
}
}
?>

View File

@@ -1,13 +1,13 @@
<?php
include_once "../../global.inc.php";
include_once PATH_DATABASE . "/SQLManager.php";
include_once PATH_DATABASE . "/SqlManager.php";
/**
* The SQLManager manage the SQL-Connection for an API
*
* @author stubbfel
*/
class HelloApiSQLManager extends SQLManager{
class HelloApiSQLManager extends SqlManager{
public function __construct() {
parent::__construct();

View File

@@ -1,14 +1,28 @@
<?php
include_once "../../global.inc.php";
include_once PATH_DATABASE . "/SQLManager.php";
include_once PATH_DATABASE . "/SpsSqlManager.php";
include_once PATH_DATABASE . "/SqlManager.php";
/**
* Description of SpsSqlManager
*
* @author stubbfel
*/
class SpsSqlManager {
//put your code here
class SpsSqlManager extends SQLManager{
public function __construct() {
parent::__construct();
}
public function __destruct() {
parent::__destruct();
}
public function sendSpsQuery($queryArgs = array()) {
// TODO Input validitaion
$alias = $queryArgs["alias"];
return $this->query("SELECT * FROM sps Where alias = \"$alias\"");
}
}
?>

View File

@@ -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;
}
}

View File

@@ -0,0 +1,2 @@
RewriteEngine on
RewriteRule ^ index.php [QSA,L]

View File

@@ -0,0 +1,15 @@
<?php
include_once "../../global.inc.php";
require_once PATH_API . "/SpsApi.php";
$app = new SpsApi();
$app->get('/alias/:alias', function ($alias) use ($app) {
$args =array();
$args["alias"] = $alias;
print_r($app->sendSpsQuery($args));
});
$app->run();
?>