t2asol

5
CSCI 5333.1 DBMS Fall 2013 Suggested Solution to Final Examination (1) For example, minimally documented: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>CSCI 5333.1 DBMS Fall 2013 Final Examination, Question 1</title> </head> <body> <?php // Minimally documented. include('dbconfig_sakila.php'); // Get keyword using the HTTP GET method. if (array_key_exists('keyword', $_GET)) { $keyword = $_GET['keyword']; } // Get category name, film counts and actor counts $query = <<<__QUERY select concat(a.first_name, ' ', a.last_name), count(distinct fa.film_id) as NumFilms from actor a, film_actor fa where a.actor_id = fa.actor_id and (a.last_name like ? or a.first_name like ?) group by a.first_name, a.last_name; __QUERY; if ($stmt = $mysqli->prepare($query)) { $searchPattern = "%$keyword%"; $stmt->bind_param('ss', $searchPattern, $searchPattern); $stmt->execute(); $stmt->bind_result($actor, $countFilms); $stmt->store_result(); if ($stmt->num_rows > 0) {

Upload: vamsi-reddy

Post on 16-Nov-2015

214 views

Category:

Documents


2 download

DESCRIPTION

dbms

TRANSCRIPT

CSCI 5333.1 DBMSFall 2013Suggested Solution to Final Examination(1)For example, minimally documented:

CSCI 5333.1 DBMS Fall 2013 Final Examination, Question 1