示例#1
0
        public List<Movie> GetMovies()
        {
            List<Movie> currentMovies = new List<Movie>();

            queryToExecute = "SELECT * FROM movies;";
            MySqlDataReader reader = queryExecutor.ExecuteQuery(queryToExecute);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Movie movie = new Movie(
                    reader.GetInt32(0),
                    reader.GetString(1),
                    reader.GetString(2),
                    reader.GetString(3),
                    reader.GetInt32(4),
                    reader.GetInt32(5),
                    reader.GetString(6),
                    reader.GetString(7),
                    reader.GetString(8),
                    reader.GetString(9),
                    reader.GetFloat(10));

                    currentMovies.Add(movie);
                }
            }

            reader.Close();
            return currentMovies;
        }
示例#2
0
        public Movie GetMovieInfo(string name)
        {
            Movie movie = null;

            queryToExecute = string.Format("SELECT movies.id, movies.name, movies.description, " +
            "movies.genre, movies.year, movies.duration, movies.actors, movies.director, " +
            "movies.poster, movies.trailer_url, movies.rating, COUNT(comments.id)" +
            "FROM movies LEFT JOIN comments ON movies.id = comments.movie_id WHERE name = \"{0}\";", name);

            MySqlDataReader reader = queryExecutor.ExecuteQuery(queryToExecute);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    movie = new Movie(
                        reader.GetInt32(0),
                        reader.GetString(1),
                        reader.GetString(2),
                        reader.GetString(3),
                        reader.GetInt32(4),
                        reader.GetInt32(5),
                        reader.GetString(6),
                        reader.GetString(7),
                        reader.GetString(8),
                        reader.GetString(9),
                        reader.GetFloat(10),
                        reader.GetInt32(11));
                }
            }

            reader.Close();
            return movie;
        }