Overview

Namespaces

  • api
  • config
  • database
  • None
  • PHP
  • Slim
    • Exception
    • Http
    • Middleware
  • utiliy

Classes

  • PisSqlManager
  • PssSqlManager
  • SpsSqlManager
  • SqlManager
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: namespace database;
  4: 
  5: include_once "../../global.inc.php";
  6: include_once PATH_UTILITTY . "/ArrayManager.php";
  7: require_once PATH_DATABASE . "/SqlManager.php";
  8: 
  9: /**
 10:  * Description of PisSqlManager
 11:  * 
 12:  * @author stubbfel
 13:  * @since 20.06.2013
 14:  */
 15: class PisSqlManager extends SQLManager {
 16: 
 17:     /**
 18:      * Fieldname of the placeID
 19:      * @var string
 20:      */
 21:     public static $placeId = "pid";
 22: 
 23:     /**
 24:      * Fieldname of the name of the information
 25:      * @var string
 26:      */
 27:     public static $infName = "iName";
 28: 
 29:     /**
 30:      * Fieldname of the value of the information
 31:      * @var string
 32:      */
 33:     public static $infValue = "iValue";
 34: 
 35:     /**
 36:      * Fieldname of the parendId
 37:      * @var string
 38:      */
 39:     public static $parentId = "parent";
 40: 
 41:     /**
 42:      * Fieldname of the refpoint
 43:      * @var string
 44:      */
 45:     public static $refpoint = "refpoint";
 46: 
 47:     /**
 48:      * String for the select part of the query
 49:      * @var string
 50:      */
 51:     private static $selectTerm = "SELECT pid, parent, refpoint, iName, iValue FROM pis WHERE ";
 52: 
 53:     /**
 54:      * String for the select all part of the query
 55:      * @var string
 56:      */
 57:     private static $selectAllTerm = "SELECT pid, parent, refpoint, iName, iValue FROM pis ";
 58: 
 59:     /**
 60:      * String for the orderby part of the query
 61:      * @var string
 62:      */
 63:     private static $orderByTerm = " ORDER BY pid, iName";
 64: 
 65:     /**
 66:      * String for like-Statement fo iValue field
 67:      * @var string 
 68:      */
 69:     private static $iValueLikeTerm = "iValue LIKE ";
 70: 
 71:     /**
 72:      * String for the pid part of the query
 73:      * @var string
 74:      */
 75:     private static $pidTerm = "pid = ";
 76: 
 77:     /**
 78:      * String for the parent part of the query
 79:      * @var string
 80:      */
 81:     private static $parentTerm = "parent = ";
 82: 
 83:     /**
 84:      * String for the iName part of the query
 85:      * @var string
 86:      */
 87:     private static $iNameTerm = "iName = ";
 88: 
 89:     /**
 90:      * Variable for the max lenght of an valid pattern string
 91:      * @var int
 92:      */
 93:     private static $patterMaxLenght = 30;
 94: 
 95:     /**
 96:      * Default-Constructor
 97:      */
 98:     public function __construct() {
 99:         parent::__construct();
100:     }
101: 
102:     /**
103:      * Default-DeConstructor
104:      */
105:     public function __destruct() {
106:         parent::__destruct();
107:     }
108: 
109:     /**
110:      * Methods send an query for the pis-service
111:      * @param array $queryArgs
112:      * @return array [num][assoc]
113:      */
114:     public function sendPisQuery($pidList, $parentId, $iNameList, $iPatter = "*") {
115: 
116:         // build query string
117:         $query = self::$selectTerm;
118:         if (\utiliy\ArrayManager::validIntList($pidList)) {
119:             $query .= self::$openBracket;
120:             $query .= \utiliy\ArrayManager::toSqlWhereString($pidList, self::$orTerm, self::$pidTerm);
121:             $query .= self::$closeBracket;
122:         } else if ($pidList[0] != "*") {
123:             return null;
124:         }
125: 
126:         if ($parentId != "*" && \utiliy\StringManager::validInt($parentId)) {
127:             if ($query != self::$selectTerm) {
128:                 $query .= self::$andTerm;
129:             }
130:             $query .= self::$parentTerm . "$parentId";
131:         }
132: 
133:         if (count($iNameList) > 0 && \utiliy\ArrayManager::validAlphaNumList($iNameList)) {
134:             if ($query != self::$selectTerm) {
135:                 $query .= self::$andTerm;
136:             }
137:             $query .= self::$openBracket;
138:             $query .= \utiliy\ArrayManager::toSqlWhereString($iNameList, self::$orTerm, self::$iNameTerm);
139:             $query .= self::$closeBracket;
140:         }
141: 
142:         if ($iPatter != "*" && $this->validIPatter($iPatter)) {
143:             if ($query != self::$selectTerm) {
144:                 $query .= self::$andTerm;
145:             }
146:             $query .= self::$iValueLikeTerm . "'%$iPatter%'";
147:         }
148: 
149:         if ($query == self::$selectTerm) {
150:             $query = self::$selectAllTerm;
151:         }
152: 
153:         $query .= self::$orderByTerm;
154: 
155:         // send query
156:         return $this->query($query);
157:     }
158: 
159:     /**
160:      * Method check if the input value for pattern string is valid
161:      * @param string $domain
162:      * @return boolean
163:      */
164:     private function validIPatter($iPatter) {
165:         if (\utiliy\StringManager::validSQLString($iPatter) && ctype_alnum($iPatter) && strlen($iPatter) <= self::$patterMaxLenght) {
166:             return TRUE;
167:         }
168:         return FALSE;
169:     }
170: 
171: }
172: 
173: ?>
174: 
GeoApi API documentation generated by ApiGen 2.8.0