add pss #62
This commit is contained in:
@@ -42,7 +42,7 @@ class PisSqlManager extends SQLManager {
|
||||
* String for the orderby part of the query
|
||||
* @var string
|
||||
*/
|
||||
private $orderByTerm = " ORDER BY pid";
|
||||
private $orderByTerm = " ORDER BY pid, iName";
|
||||
|
||||
/**
|
||||
* String for the pid part of the query
|
||||
@@ -73,44 +73,15 @@ class PisSqlManager extends SQLManager {
|
||||
|
||||
// build query string
|
||||
$query = $this->selectTerm;
|
||||
if ($this->validPidList($queryArgs)) {
|
||||
$query .= $this->createPidWhereString($queryArgs) . $this->orderByTerm;
|
||||
if (\utiliy\ArrayManager::validIntList($queryArgs)) {
|
||||
$query .= \utiliy\ArrayManager::toSqlWhereString($queryArgs, $this->orTerm, $this->pidTerm) . $this->orderByTerm;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
// send query
|
||||
return $this->query($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method check if all items of the pidlist are orly digits
|
||||
* @param array $poly
|
||||
* @return boolean
|
||||
*/
|
||||
private function validPidList($pidList) {
|
||||
foreach ($pidList as $value) {
|
||||
|
||||
if (!ctype_digit($value) || PHP_INT_MAX < $value) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method convert a pidList to a where-string
|
||||
* @param array $pidList
|
||||
* @return string
|
||||
*/
|
||||
private function createPidWhereString($pidList) {
|
||||
$pidListStr = \utiliy\StringManager::$emptyString;
|
||||
foreach ($pidList as $value) {
|
||||
$pidListStr .= $this->pidTerm . $value . $this->orTerm;
|
||||
}
|
||||
$result = substr($pidListStr, 0, strlen($pidListStr) - strlen($this->orTerm));
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
95
geoapi/database/PssSqlManager.php
Normal file
95
geoapi/database/PssSqlManager.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace database;
|
||||
|
||||
include_once "../../global.inc.php";
|
||||
include_once PATH_UTILITTY . "/ArrayManager.php";
|
||||
require_once PATH_DATABASE . "/SqlManager.php";
|
||||
|
||||
/**
|
||||
* Description of ZisSqlManager
|
||||
*
|
||||
* @author stubbfel
|
||||
* @since 20.06.2013
|
||||
*/
|
||||
class PssSqlManager extends SQLManager {
|
||||
|
||||
/**
|
||||
* Fieldname of the placeID
|
||||
* @var string
|
||||
*/
|
||||
public static $placeId = "pid";
|
||||
|
||||
/**
|
||||
* Fieldname of the name of the service
|
||||
* @var string
|
||||
*/
|
||||
public static $srvName = "sName";
|
||||
|
||||
/**
|
||||
* Fieldname of the value of the information
|
||||
* @var string
|
||||
*/
|
||||
public static $srvSap = "sap";
|
||||
|
||||
/**
|
||||
* Fieldname of the value of the information
|
||||
* @var string
|
||||
*/
|
||||
public static $srvRequest = "request";
|
||||
|
||||
/**
|
||||
* String for the select part of the query
|
||||
* @var string
|
||||
*/
|
||||
private $selectTerm = "SELECT pid, sName, sap, request FROM pss WHERE ";
|
||||
|
||||
/**
|
||||
* String for the orderby part of the query
|
||||
* @var string
|
||||
*/
|
||||
private $orderByTerm = " ORDER BY pid, sName";
|
||||
|
||||
/**
|
||||
* String for the pid part of the query
|
||||
* @var string
|
||||
*/
|
||||
private $pidTerm = "pid = ";
|
||||
|
||||
/**
|
||||
* Default-Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default-DEConstructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
parent::__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Methods send an query for the pis-service
|
||||
* @param array $queryArgs
|
||||
* @return array [num][assoc]
|
||||
*/
|
||||
public function sendPssQuery($queryArgs) {
|
||||
|
||||
// build query string
|
||||
$query = $this->selectTerm;
|
||||
|
||||
if (\utiliy\ArrayManager::validIntList($queryArgs)) {
|
||||
$query .= \utiliy\ArrayManager::toSqlWhereString($queryArgs, $this->orTerm, $this->pidTerm) . $this->orderByTerm;
|
||||
} else {
|
||||
return null;
|
||||
};
|
||||
|
||||
// send query
|
||||
return $this->query($query);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -14,20 +14,6 @@ require_once PATH_DATABASE . "/SqlManager.php";
|
||||
*/
|
||||
class SpsSqlManager extends SQLManager {
|
||||
|
||||
/**
|
||||
* Default-Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default-DEConstructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
parent::__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fieldname of the placeID
|
||||
* @var string
|
||||
@@ -100,6 +86,20 @@ class SpsSqlManager extends SQLManager {
|
||||
*/
|
||||
private $domainMaxLenght = 32;
|
||||
|
||||
/**
|
||||
* Default-Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default-DEConstructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
parent::__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Methods send an query for the sps-service depends of alias
|
||||
* @param array $queryArgs
|
||||
@@ -185,7 +185,7 @@ class SpsSqlManager extends SQLManager {
|
||||
* @return boolean
|
||||
*/
|
||||
private function validAliasString($alias) {
|
||||
if ($this->validString($alias) && ctype_alnum($alias) && strlen($alias) <= $this->aliasMaxLenght) {
|
||||
if (\utiliy\StringManager::validSQLString($alias) && ctype_alnum($alias) && strlen($alias) <= $this->aliasMaxLenght) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -197,7 +197,7 @@ class SpsSqlManager extends SQLManager {
|
||||
* @return boolean
|
||||
*/
|
||||
private function validDomainString($domain) {
|
||||
if ($this->validString($domain) && ctype_alnum($domain) && strlen($domain) <= $this->domainMaxLenght) {
|
||||
if (\utiliy\StringManager::validSQLString($domain) && ctype_alnum($domain) && strlen($domain) <= $this->domainMaxLenght) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -209,7 +209,7 @@ class SpsSqlManager extends SQLManager {
|
||||
* @return boolean
|
||||
*/
|
||||
private function validPolyString($poly) {
|
||||
if ($this->validString($poly) && \utiliy\StringManager::startsWith($poly, $this->polyStartStr) && \utiliy\StringManager::endsWith($poly, $this->polyEndStr)) {
|
||||
if (\utiliy\StringManager::validSQLString($poly) && \utiliy\StringManager::startsWith($poly, $this->polyStartStr) && \utiliy\StringManager::endsWith($poly, $this->polyEndStr)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
@@ -129,19 +129,6 @@ abstract class SqlManager {
|
||||
mysql_free_result($mysqlResult);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method if the string is not a empty String (not only spaces and controlls)
|
||||
* @param string $string
|
||||
* @return boolean
|
||||
*/
|
||||
protected function validString($string) {
|
||||
if (!ctype_space($string) && !ctype_cntrl($string)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user