This commit is contained in:
stubbfel
2013-06-20 11:26:10 +02:00
parent 0f21ccfe25
commit 61f8cbbf4f
92 changed files with 33401 additions and 30 deletions

View File

@@ -5,11 +5,25 @@ include_once PATH_DATABASE . "/SQLManager.php";
require_once PATH_3PARTY . "/Slim/Slim.php";
\Slim\Slim::registerAutoloader();
namespace api;
/**
* This class provides some general API methods
* @author stubbfel
* @since 20.06.2013
*/
abstract class Api extends \Slim\Slim {
/**
* Variable for the sql manager of the api
* @var <T>:SqlManager
*/
protected $sqlManager;
public function __construct() {
/**
* Default-Constructor
*/
public function Api() {
if (!$this->sqlManager) {
echo "bla";
$this->sqlManager = new SQLManager();
@@ -17,11 +31,16 @@ abstract class Api extends \Slim\Slim {
parent::__construct();
}
/**
* Default-DeConstructor
*/
public function __destruct() {
$this->sqlManager = null;
//parent::__destruct();
}
/**
* Method start a connection to the database
*/
public function connect() {
$this->sqlManager->connect();
}

View File

@@ -1,27 +1,31 @@
<?php
include_once "../../global.inc.php";
require_once PATH_API."/Api.php";
include_once "../../global.inc.php";
require_once PATH_API . "/Api.php";
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace api;
/**
* Description of HelloApi
*
* This class provides some spezial SpsAPI methods
* @author stubbfel
* @since 20.06.2013
*/
class SpsApi extends Api{
public function __construct() {
class SpsApi extends Api {
/**
* Default-Constructor
*/
public function SpsApi() {
parent::__construct();
}
/**
* Default-DeConstructor
*/
public function __destruct() {
parent::__destruct();
}
}
?>

View File

@@ -1,7 +1,24 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
namespace config;
/**
* Address of the sqlserver
*/
$sqlServer = "localhost";
/**
* name of the database
*/
$sqlDBName = "geoDB";
/**
* user of the database
*/
$sqlDBUser = "geoDB";
/**
* password of the database
*/
$sqlDBUserPW = "VZrSAYvmcrntQ97b"
?>

View File

@@ -7,7 +7,7 @@ include_once PATH_DATABASE . "/SQLManager.php";
*
* @author stubbfel
*/
class HelloApiSQLManager extends SQLManager{
class HelloApiSQLManager extends \database\SQLManager{
public function __construct() {
parent::__construct();

View File

@@ -2,49 +2,100 @@
include_once "../../global.inc.php";
namespace database;
/**
* The SQLManager manage the SQL-Connection for an API
*
* @author stubbfel
* @since 20.06.2013
*/
class SQLManager {
/**
* Variable for address of the server
* @var string
*/
private $serverAddress;
/**
* Variable for name of the databaseuser
* @var string
*/
private $userName;
/**
* Variable for name of the database
* @var string
*/
private $dbName;
/**
* Variable for password of the user
* @var string
*/
private $userPw;
/**
* Variable for link of the connection to the server
* @var connection
*/
private $link;
public function __construct() {
include_once PATH_DATABASE . "/mysql.php";
/**
* Default-Constructor
*/
public function SQLManager() {
include_once PATH_CONFIG . "/config.db.php";
$this->serverAddress = $sqlServer;
$this->dbName = $sqlDBName;
$this->userName = $sqlDBUser;
$this->userPw = $sqlDBUserPW;
}
/**
* Default-DEConstructor
*/
public function __destruct() {
$this->close();
$this->closeConnection();
$this->serverAddress = null;
$this->dbName = null;
$this->userName = null;
$this->userPW = null;
}
/**
* Method setup the connection to the Database
*/
public function connect() {
$this->link = mysql_connect($this->serverAddress, $this->userName, $this->userPw) or die("No Connection: " . mysql_error());
mysql_select_db($this->dbName, $this->link) or die("No DB: " . mysql_error());
$this->link = mysql_connect($this->serverAddress, $this->userName, $this->userPw);
if (!$this->link) {
exit("No Connection: " . mysql_error());
}
$selected = mysql_select_db($this->dbName, $this->link);
if (!$selected) {
exit("No DB: " . mysql_error());
}
}
public function close() {
/**
* Method close the connection
*/
public function closeConnection() {
if ($this->link) {
mysql_close($this->link);
}
}
/**
* Method send a query to the Datebase and return the result
* @param string $query
* @return result[num][assoc]
*/
protected function query($query) {
$mysqlResult = mysql_query($query, $this->link) or die("Query error: " . mysql_error());
$mysqlResult = mysql_query($query, $this->link);
if (!$mysqlResult) {
exit("Query error: " . mysql_error());
}
$rowNums = mysql_num_rows($mysqlResult);
$result = array();
for ($i = 0; $i < $rowNums; $i++) {

View File

@@ -2,10 +2,13 @@
include_once "../../global.inc.php";
include_once PATH_DATABASE . "/SQLManager.php";
namespace database;
/**
* Description of SpsSqlManager
*
*
* @author stubbfel
* @since 20.06.2013
*/
class SpsSqlManager {
//put your code here

View File

@@ -1,7 +1,32 @@
<?php
/**
* Path to the root
*/
define("PATH_ROOT", dirname(__FILE__));
define("PATH_SERVICES", PATH_ROOT. "/service");
/**
* Path to the services
*/
define("PATH_SERVICES", PATH_ROOT . "/service");
/**
* Path to the thirdparties
*/
define("PATH_3PARTY", PATH_ROOT . "/thirdparty");
/**
* Path to the apis
*/
define("PATH_API", PATH_ROOT . "/api");
define("PATH_DATABASE", PATH_ROOT. "/database");
/**
* Path to the database
*/
define("PATH_DATABASE", PATH_ROOT . "/database");
/**
* Path to the config
*/
define("PATH_CONFIG", PATH_ROOT . "/config");
?>