public static function ExtractSession($data, $singleResult = false, $SessionExtension = '', $isResult = true) { // generates an assoc array of sessions by using a defined list // of its attributes $res = DBJson::getResultObjectsByAttributes($data, Session::getDBPrimaryKey(), Session::getDBConvert(), $SessionExtension); if ($isResult) { $res = Session::decodeSession($res, false); if ($singleResult == true) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } } return $res; }
public static function ExtractApprovalCondition($data, $singleResult = false, $ApprovalExtension = '', $isResult = true) { // generates an assoc array of an approval condition by using a // defined list of its attributes $res = DBJson::getResultObjectsByAttributes($data, ApprovalCondition::getDBPrimaryKey(), ApprovalCondition::getDBConvert(), $ApprovalExtension); if ($isResult) { // to reindex $res = array_merge($res); $res = ApprovalCondition::decodeApprovalCondition($res, false); if ($singleResult == true) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } } return $res; }
public static function ExtractExerciseFileType($data, $singleResult = false, $FileTypeExtension = '', $isResult = true) { // generates an assoc array of an exercise file type by using a defined // list of its attributes $res = DBJson::getResultObjectsByAttributes($data, ExerciseFileType::getDBPrimaryKey(), ExerciseFileType::getDBConvert(), $FileTypeExtension); if ($isResult) { // to reindex $res = array_merge($res); $res = ExerciseFileType::decodeExerciseFileType($res, false); if ($singleResult == true) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } } return $res; }
public static function ExtractBEISPIEL($data) { $res = DBJson::getResultObjectsByAttributes($data, BEISPIEL::getDBPrimaryKey(), BEISPIEL::getDBConvert()); return $res; }
public static function ExtractChoice($data, $singleResult = false, $ChoiceExtension = '', $isResult = true) { // generates an assoc array of choices by using a defined list of // its attributes $res = DBJson::getResultObjectsByAttributes($data, Choice::getDBPrimaryKey(), Choice::getDBConvert(), $ChoiceExtension); if ($isResult) { // to reindex $res = array_values($res); $res = Choice::decodeChoice($res, false); if ($singleResult == true) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } } return $res; }
/** * Returns a specific component. * * @param $componentid a database component identifier */ public function getComponent($componentid) { // checks whether incoming data has the correct data type DBJson::checkInput($this->_app, ctype_digit($componentid)); // starts a query ob_start(); eval("?>" . file_get_contents(dirname(__FILE__) . '/Sql/GetComponent.sql')); $sql = ob_get_contents(); ob_end_clean(); $result = DBRequest::request($sql, false, parse_ini_file(dirname(__FILE__) . '/config.ini', TRUE)); // checks the correctness of the query if ((!isset($result['errno']) || !$result['errno']) && $result['content']) { $data = DBJson::getRows($result['content']); $components = DBJson::getResultObjectsByAttributes($data, Component::getDBPrimaryKey(), Component::getDBConvert()); $this->_app->response->setBody(json_encode($components)); $this->_app->response->setStatus(200); } else { Logger::Log('GET GetComponent failed', LogLevel::ERROR); $this->_app->response->setStatus(409); } }
public static function ExtractFile($data, $singleResult = false) { // generates an assoc array of files by using a defined list of // its attributes $res = DBJson::getResultObjectsByAttributes($data, File::getDBPrimaryKey(), File::getDBConvert()); $res = File::decodeFile($res, false); if ($singleResult == true) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } return $res; }