Overview

Namespaces

  • None
  • PHP
  • Slim
    • Exception
    • Http
    • Middleware

Classes

  • Api
  • HelloApi
  • HelloApiSQLManager
  • SpsApi
  • SpsSqlManager
  • SQLManager
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: include_once "../../global.inc.php";
 4: 
 5: /**
 6:  * The SQLManager manage the SQL-Connection for an API
 7:  *
 8:  * @author stubbfel
 9:  */
10: class SQLManager {
11: 
12:     private $serverAddress;
13:     private $userName;
14:     private $dbName;
15:     private $userPw;
16:     private $link;
17: 
18:     public function __construct() {
19:         include_once PATH_DATABASE . "/mysql.php";
20:         $this->serverAddress = $sqlServer;
21:         $this->dbName = $sqlDBName;
22:         $this->userName = $sqlDBUser;
23:         $this->userPw = $sqlDBUserPW;
24:     }
25: 
26:     public function __destruct() {
27:         $this->close();
28:         $this->serverAddress = null;
29:         $this->dbName = null;
30:         $this->userName = null;
31:         $this->userPW = null;
32:     }
33: 
34:     public function connect() {
35:         $this->link = mysql_connect($this->serverAddress, $this->userName, $this->userPw) or die("No Connection: " . mysql_error());
36:         mysql_select_db($this->dbName, $this->link) or die("No DB: " . mysql_error());
37:     }
38: 
39:     public function close() {
40:         if ($this->link) {
41:             mysql_close($this->link);
42:         }
43:     }
44: 
45:     protected function query($query) {
46:         $mysqlResult = mysql_query($query, $this->link) or die("Query error: " . mysql_error());
47: 
48:         $rowNums = mysql_num_rows($mysqlResult);
49:         $result = array();
50:         for ($i = 0; $i < $rowNums; $i++) {
51:             $row = mysql_fetch_assoc($mysqlResult);
52:             $result[$i] = $row;
53:         }
54:         mysql_free_result($mysqlResult);
55:         return $result;
56:     }
57: 
58: }
59: 
60: ?>
61: 
GeoApi API documentation generated by ApiGen 2.8.0