Ejemplo n.º 1
0
 public function post_index()
 {
     $new = new Movies();
     $new->save();
     $response = array('success' => true, 'data' => array('id' => $new->id));
     $json = json_encode($response);
     return $json;
 }
Ejemplo n.º 2
0
 public function action_index()
 {
     $record = new Movies();
     $record->title = $_POST['title'];
     $record->year = $_POST['year'];
     $record->save();
     $array = array('success' => 'true', 'msg' => 'Record added successfully');
     $json = json_encode($array);
     return $json;
 }
Ejemplo n.º 3
0
 public function post_index()
 {
     $data = file_get_contents('php://input');
     $temp = json_decode($data);
     $new = new Movies();
     $new->text = $temp->text;
     $new->parent_id = $temp->parentId;
     $new->leaf = $temp->leaf;
     $new->save();
     $response = array('success' => true, 'data' => array('id' => $new->id));
     $json = json_encode($response);
     return $json;
 }
 /**
  * testAddNewRecordException.
  *
  * Exception is thrown when querying to or from a table that
  * does not exist
  *
  * @expectedException PDOException
  */
 public function testAddNewRecordException()
 {
     $movie = new Movies();
     $movie->name = 'Deadpool';
     $movieId = $movie->save();
 }
Ejemplo n.º 5
0
 public function getDoubanMovieAction($doubanid)
 {
     $movie = Movies::findFirst(['conditions' => 'doubanid = :doubanid:', 'bind' => ['doubanid' => $doubanid]]);
     if (!$movie) {
         $data = (new doubanmovie())->getinfo($doubanid);
         //异常处理如何做?
         //            var_dump($data);die();
         $movie = new Movies();
         $movie->save($data);
     }
     return $this->redirectByRoute(['for' => 'movies.show', 'movie' => $movie->id]);
 }