finish #69
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
namespace database;
|
||||
|
||||
include_once "../../global.inc.php";
|
||||
include_once PATH_UTILITTY . "/StringManager.php";
|
||||
include_once PATH_UTILITTY . "/ArrayManager.php";
|
||||
require_once PATH_DATABASE . "/SqlManager.php";
|
||||
|
||||
/**
|
||||
@@ -50,6 +50,12 @@ class PisSqlManager extends SQLManager {
|
||||
*/
|
||||
private static $pidTerm = "pid = ";
|
||||
|
||||
/**
|
||||
* String for the iName part of the query
|
||||
* @var string
|
||||
*/
|
||||
private static $iNameTerm = "iName = ";
|
||||
|
||||
/**
|
||||
* Default-Constructor
|
||||
*/
|
||||
@@ -69,19 +75,31 @@ class PisSqlManager extends SQLManager {
|
||||
* @param array $queryArgs
|
||||
* @return array [num][assoc]
|
||||
*/
|
||||
public function sendPisQuery($queryArgs) {
|
||||
public function sendPisQuery($pidList, $iNameList) {
|
||||
|
||||
// build query string
|
||||
$query = self::$selectTerm;
|
||||
if (\utiliy\ArrayManager::validIntList($queryArgs)) {
|
||||
$query .= \utiliy\ArrayManager::toSqlWhereString($queryArgs, self::$orTerm, self::$pidTerm) . self::$orderByTerm;
|
||||
if (\utiliy\ArrayManager::validIntList($pidList)) {
|
||||
$query .= self::$openBracket;
|
||||
$query .= \utiliy\ArrayManager::toSqlWhereString($pidList, self::$orTerm, self::$pidTerm);
|
||||
$query .= self::$closeBracket;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (count($iNameList) > 0 && \utiliy\ArrayManager::validAlphaNumList($iNameList)) {
|
||||
$query .= self::$andTerm;
|
||||
$query .= self::$openBracket;
|
||||
$query .= \utiliy\ArrayManager::toSqlWhereString($iNameList, self::$orTerm, self::$iNameTerm);
|
||||
$query .= self::$closeBracket;
|
||||
}
|
||||
|
||||
$query .= self::$orderByTerm;
|
||||
|
||||
// send query
|
||||
return $this->query($query);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -60,6 +60,18 @@ abstract class SqlManager {
|
||||
*/
|
||||
protected static $quoteTerm = "\"";
|
||||
|
||||
/**
|
||||
* String for open Bracket in a query
|
||||
* @var string
|
||||
*/
|
||||
protected static $openBracket = "(";
|
||||
|
||||
/**
|
||||
* String for close Bracket in a query
|
||||
* @var string
|
||||
*/
|
||||
protected static $closeBracket = ")";
|
||||
|
||||
/**
|
||||
* Default-Constructor
|
||||
*/
|
||||
@@ -67,7 +79,9 @@ abstract class SqlManager {
|
||||
$this->serverAddress = \config\DBConfig::$sqlServer;
|
||||
$this->dbName = \config\DBConfig::$sqlDBName;
|
||||
$this->userName = \config\DBConfig::$sqlDBUser;
|
||||
$this->userPw = \config\DBConfig::$sqlDBUserPW;
|
||||
$this->userPw = \config\DBConfig::$sqlDBUserPW
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,18 +96,20 @@ abstract class SqlManager {
|
||||
unset($this->serverAddress);
|
||||
unset($this->dbName);
|
||||
unset($this->userName);
|
||||
unset($this->userPW);
|
||||
unset($this->userPW
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setup the connection to the Database
|
||||
*/
|
||||
public function connect() {
|
||||
$this->link = mysql_connect($this->serverAddress, $this->userName, $this->userPw);
|
||||
$this->link = mysql_connect($this->serverAddress , $this->userName , $this->userPw);
|
||||
if (!$this->link) {
|
||||
exit("No Connection: " . mysql_error());
|
||||
}
|
||||
$selected = mysql_select_db($this->dbName, $this->link);
|
||||
$selected = mysql_select_db($this->dbName , $this->link);
|
||||
if (!$selected) {
|
||||
exit("No DB: " . mysql_error());
|
||||
}
|
||||
@@ -103,7 +119,9 @@ abstract class SqlManager {
|
||||
* Method close the connection
|
||||
*/
|
||||
public function closeConnection() {
|
||||
if ($this->link) {
|
||||
if (
|
||||
|
||||
$this->link) {
|
||||
mysql_close($this->link);
|
||||
unset($this->link);
|
||||
$this->link = null;
|
||||
@@ -113,20 +131,23 @@ abstract class SqlManager {
|
||||
/**
|
||||
* Method send a query to the Datebase and return the result
|
||||
* @param string $query
|
||||
|
||||
|
||||
* @return result[num][assoc]
|
||||
*/
|
||||
protected function query($query) {
|
||||
|
||||
// send error
|
||||
$mysqlResult = mysql_query($query, $this->link);
|
||||
$mysqlResult = mysql_query($query, $this->link );
|
||||
if (!$mysqlResult) {
|
||||
// echo $query;
|
||||
exit("Query error: " . mysql_error());
|
||||
}
|
||||
|
||||
// fetch result
|
||||
$rowNums = mysql_num_rows($mysqlResult);
|
||||
$result = array();
|
||||
for ($i = 0; $i < $rowNums; $i++) {
|
||||
for ($i = 0; $i < $rowNums; $i++) {
|
||||
$row = mysql_fetch_assoc($mysqlResult);
|
||||
$result[$i] = $row;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user