add SQCManager

This commit is contained in:
stubbfel
2013-06-19 14:59:42 +02:00
parent 0d529ba7cb
commit 5ba6ca8387
9 changed files with 205 additions and 9 deletions

View File

@@ -0,0 +1,26 @@
<?php
include_once "../../global.inc.php";
include_once PATH_DATABASE . "/SQLManager.php";
/**
* The SQLManager manage the SQL-Connection for an API
*
* @author stubbfel
*/
class HelloApiSQLManager extends SQLManager{
public function __construct() {
parent::__construct();
}
public function __destruct() {
parent::__destruct();
}
public function sendHelloQuery() {
return $this->query("SELECT * FROM sps");
}
}
?>

View File

@@ -0,0 +1,60 @@
<?php
include_once "../../global.inc.php";
/**
* The SQLManager manage the SQL-Connection for an API
*
* @author stubbfel
*/
class SQLManager {
private $serverAddress;
private $userName;
private $dbName;
private $userPw;
private $link;
public function __construct() {
include_once PATH_DATABASE . "/mysql.php";
$this->serverAddress = $sqlServer;
$this->dbName = $sqlDBName;
$this->userName = $sqlDBUser;
$this->userPw = $sqlDBUserPW;
}
public function __destruct() {
$this->close();
$this->serverAddress = null;
$this->dbName = null;
$this->userName = null;
$this->userPW = null;
}
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());
}
public function close() {
if ($this->link) {
mysql_close($this->link);
}
}
protected function query($query) {
$mysqlResult = mysql_query($query, $this->link) or die("Query error: " . mysql_error());
$rowNums = mysql_num_rows($mysqlResult);
$result = array();
for ($i = 0; $i < $rowNums; $i++) {
$row = mysql_fetch_assoc($mysqlResult);
$result[$i] = $row;
}
mysql_free_result($mysqlResult);
return $result;
}
}
?>

View File

@@ -0,0 +1,14 @@
<?php
include_once "../../global.inc.php";
include_once PATH_DATABASE . "/SQLManager.php";
/**
* Description of SpsSqlManager
*
* @author stubbfel
*/
class SpsSqlManager {
//put your code here
}
?>

View File

@@ -1,7 +1,8 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
$sqlServer = "localhost";
$sqlDBName = "geoDB";
$sqlDBUser = "geoDB";
$sqlDBUserPW = "VZrSAYvmcrntQ97b"
?>