public function saveCinemaSession(cw_cinema_sessions $status)
 {
     $query = $status->getId() ? 'UPDATE cw_cinema_sessions
                                SET idMovie = :idMovie,
                                    idTheater = :idTheater,
                                    date = :date,
                                    language = :language,
                                    subModels :subModels,
                                    archive :archive
                                WHERE id = :id' : 'INSERT INTO cw_cinema_sessions
                                (id, idMovie, idTheater, date, language, subModels, archive)
                                VALUES
                                (:id, :idMovie, :idTheater, :date, :language, :subModels, :archive)';
     $query = $this->db->prepare($query);
     $query->execute(['id' => $status->getId(), 'idTheater' => $status->getIdTheater(), 'idMovie' => $status->getIdMovie(), 'date' => $status->getDate(), 'language' => $status->getLanguage(), 'subModels' => $status->getsubModels(), 'archive' => $status->getArchive()]);
     return $this->db->lastInsertId();
 }
Esempio n. 2
0
<?php

use Cinewax\Api\Models\Cinewax\cw_cinema_sessions;
use silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$app->post('/addCinemaSessions', function (Application $app, Request $request) {
    $status = new cw_cinema_sessions();
    $status->setIdMovie($request->request->get('idMovie'));
    $status->setIdTheater($request->request->get('idTheater'));
    $status->setDate($request->request->get('date'));
    $status->setLanguage($request->request->get('language'));
    $status->setSubModels($request->request->get('setSubModels'));
    $status->setArchive($request->request->get('archive'));
    $id = $app['repo.cinemaSessions']->saveCinemaSession($status);
    $response = new Response(null, 201);
    $response->headers->set('Location', $app['url_generator']->generate('status', ['status' => $id]));
    return $response;
});