This commit is contained in:
stubbfel
2013-06-26 14:00:16 +02:00
parent 27604f0c3f
commit 34c0549ac8
12 changed files with 338 additions and 98 deletions

View File

@@ -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;
}
}
?>