/** * @param Komentaras $komentaras * @return array */ public function save(Komentaras $komentaras) { $response = []; try { $query = $this->db->prepare("INSERT INTO komentarai(`temos_id`, `komentaras`, `autorius`, `data`) VALUES(:temos_id, :komentaras, :autorius, :data)"); $query->bindParam(':temos_id', $komentaras->getTemosId(), \PDO::PARAM_INT); $query->bindParam(':komentaras', $komentaras->getKomentaras(), \PDO::PARAM_STR); $query->bindParam(':autorius', $komentaras->getAutorius(), \PDO::PARAM_STR); $query->bindParam(':data', $komentaras->getData(), \PDO::PARAM_STR); $query->execute(); $response['status'] = 'success'; } catch (\Exception $e) { $response['status'] = 'failed'; $response['message'] = $e->getMessage(); } return $response; }