public static function doAction($action, $id) { switch ($action) { case 'showList': $out = Auto::getAll(); $out = self::transform($out); break; case 'showUpdate': $out = Auto::getById($id); $out = self::transformUpdate($out); break; case 'showInsert': $out = self::transformUpdate(); break; case 'update': $autoFiltered = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS); $hersteller_idFiltered = filter_input(INPUT_POST, 'hersteller_id', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS); $kennzeichenFiltered = filter_input(INPUT_POST, 'kennzeichen', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS); $updateautoidFiltered = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT & FILTER_SANITIZE_SPECIAL_CHARS); $out = new Auto($autoFiltered, Hersteller::getById($hersteller_idFiltered), $kennzeichenFiltered, $updateautoidFiltered); $out = Auto::update($out); $out = Auto::getAll(); $out = self::transform($out); break; case 'insert': $autoFiltered = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS); $hersteller_idFiltered = filter_input(INPUT_POST, 'hersteller_id', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS); $kennzeichenFiltered = filter_input(INPUT_POST, 'kennzeichen', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS); $out = new Auto($autoFiltered, Hersteller::getById($hersteller_idFiltered), $kennzeichenFiltered, NULL); $out = Auto::insert($out); $out = Auto::getAll(); $out = self::transform($out); break; case 'delete': $deleteautoidFiltered = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT & FILTER_SANITIZE_SPECIAL_CHARS); $out = $deleteautoidFiltered; $out = Auto::delete($out); $out = Auto::getAll(); $out = self::transform($out); break; default: break; } return $out; }
public static function doAction($action, &$view, $id) { switch ($action) { case 'showList': $out = Auto::getAll(); $out = self::transform($out); break; case 'showUpdate': $out = Auto::getById($id); $out = self::transformUpdate($out); break; case 'showInsert': $out = self::transformUpdate(); break; case 'update': $daten = $_POST['daten']; $daten = json_decode($daten, FALSE); $out = new Auto($daten->auto, Hersteller::getById($daten->hersteller_id), $daten->kennzeichen, $daten->uauid); $out = Auto::update($out); $out = Auto::getAll(); $out = self::transform($out); break; case 'insert': $daten = $_POST['daten']; $daten = json_decode($daten, FALSE); $out = new Auto($daten->auto, Hersteller::getById($daten->hersteller_id), $daten->kennzeichen, NULL); $out = Auto::insert($out); $out = Auto::getAll(); $out = self::transform($out); break; case 'delete': $out = $_POST['lauid']; $out = Auto::delete($out); $out = Auto::getAll(); $out = self::transform($out); break; default: break; } return $out; }