add SQCManager
This commit is contained in:
26
geoapi/database/HelloApiSQLManager.php
Normal file
26
geoapi/database/HelloApiSQLManager.php
Normal 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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
60
geoapi/database/SQLManager.php
Normal file
60
geoapi/database/SQLManager.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
14
geoapi/database/SpsSqlManager.php
Normal file
14
geoapi/database/SpsSqlManager.php
Normal 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
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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"
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user