public function get($functionName, $sqlFile, $formid, $courseid, $esid, $eid, $singleResult = false, $checkSession = true) { Logger::Log('starts GET ' . $functionName, LogLevel::DEBUG); // checks whether incoming data has the correct data type $formid = DBJson::mysql_real_escape_string($formid); DBJson::checkInput($this->_app, $courseid == '' ? true : ctype_digit($courseid), $esid == '' ? true : ctype_digit($esid), $eid == '' ? true : ctype_digit($eid)); // starts a query, by using a given file $result = DBRequest::getRoutedSqlFile($this->query, $sqlFile, array('formid' => $formid, 'courseid' => $courseid, 'esid' => $esid, 'eid' => $eid), $checkSession); // checks the correctness of the query if ($result['status'] >= 200 && $result['status'] <= 299) { $query = Query::decodeQuery($result['content']); if (is_array($query)) { $query = $query[count($query) - 1]; } if ($query->getNumRows() > 0) { $res = Form::ExtractForm($query->getResponse(), $singleResult); $this->_app->response->setBody(Form::encodeForm($res)); $this->_app->response->setStatus(200); if (isset($result['headers']['Content-Type'])) { $this->_app->response->headers->set('Content-Type', $result['headers']['Content-Type']); } $this->_app->stop(); } else { $result['status'] = 404; } } Logger::Log('GET ' . $functionName . ' failed', LogLevel::ERROR); $this->_app->response->setStatus(isset($result['status']) ? $result['status'] : 409); $this->_app->response->setBody(Form::encodeForm(new Form())); $this->_app->stop(); }