mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 18:02:18 +00:00
Update response/error handling
This commit is contained in:
@@ -156,14 +156,21 @@ class Notiz_model extends DB_Model
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
//check if valid type
|
||||
$isValidType = $this->NotizzuordnungModel->isValidType($type);
|
||||
$result = $this->NotizzuordnungModel->isValidType($type);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
|
||||
$result = error($result->retval, EXIT_ERROR);
|
||||
return $result;
|
||||
}
|
||||
/*
|
||||
if(!$isValidType)
|
||||
{
|
||||
//Todo manu (correct return to controller)
|
||||
$msg = "datatype " . $type . " not implemented for notes";
|
||||
return error($msg, EXIT_ERROR);
|
||||
}
|
||||
}*/
|
||||
|
||||
// Start DB transaction
|
||||
$this->db->trans_start(false);
|
||||
|
||||
@@ -14,7 +14,6 @@ class Notizzuordnung_model extends DB_Model
|
||||
|
||||
public function isValidType($type)
|
||||
{
|
||||
//var_dump($type);
|
||||
$validTypes = [];
|
||||
|
||||
$qry = "
|
||||
@@ -22,24 +21,25 @@ class Notizzuordnung_model extends DB_Model
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'tbl_notizzuordnung'
|
||||
AND column_name not in ('notizzuordnung_id', 'notiz_id')
|
||||
";
|
||||
|
||||
$type_arr = $this->execQuery($qry);
|
||||
$type_arr = $type_arr->retval;
|
||||
|
||||
foreach ($type_arr as $t) {
|
||||
foreach ($type_arr as $t)
|
||||
{
|
||||
$validTypes[] = $t->column_name;
|
||||
}
|
||||
|
||||
if (in_array($type, $validTypes))
|
||||
{
|
||||
// var_dump($type . " is IN ARRAY");
|
||||
return true;
|
||||
$result = success('Type of Id is valid');
|
||||
}
|
||||
else
|
||||
{
|
||||
//var_dump($type . " is NOT IN ARRAY");
|
||||
return false;
|
||||
$result = error('Type of Id is not valid');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user