Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
COMP 3540 Advanced Web Design and Programming Term Test II – Fall 2013 Student Name: Student Number: 1. (11 marks) Fill in the blanks in each of the following. a) A _______________ is a name/value pair that is stored in the browser. b) Because HTTP is a _______________ protocol, most web applications need to use session tracking to track each user’s session. c) The _______________ pattern is commonly used to structure web applications that have significant processing requirements. d) A subclass can _______________ the superclass by adding new properties and methods. It can also override a method from the superclass with its own version of the method. e) An _______________ defines a set of public methods that can be implemented by a class. This does not provide any code to implement the methods, but it provides the method names and parameter lists. f) To work with the data in a database, you use _______________. To access and update the data in a database, you use these _______________ statements. g) To create a _______________ object that connects to a MySQL database, you use the _______________ class with three arguments: DSN, username, and password. h) Each table in a database should have a _______________ key that uniquely identifies each row. i) An _______________ improves performance when MySQL searches for rows in the table. j) A _______________ is used to combine columns from two or more tables into a result set based on the conditions you specify. k) A _______________ is special type of subpattern that must be matched for the overall pattern to be matched. 2. (3 marks) Write a PHP statement to get the value for the cookie userid; 3. (3 marks) Write the PHP code to display all the elements of an array cart that is a session variable. 4. (3 marks) Write the PHP code to create an object of the class Category, access to the property comment and invoke the method getName. 5. (3 marks) Define the class Employee that extends Person. Employee includes private ssn. Employee includes a set method to set ssn, and a get method to return ssn. 6. (3 marks) The table products includes 5 columns: productID, categoryID, productCode, productName, listPrice. Write a SQL statement to select all the rows in the descending order of categoryID where listPrice is >= 400 and listPrice is < 1000. 7. (3 marks) Assuming the same table products in 6), another table categories includes 2 columns: categoryID, categoryName. Write a SQL statement to obtain the category names of which list prices are >= 600. 8. (3 marks) Assuming the same table products in 6), write the PHP code to insert a row into the table. You can use $db as a PDO object and use any appropriate values for columns. 9. (3 marks) Assuming the same table products in 6), write the PHP code to print all rows in the table. You can use $db as a PDO object. 10. (3 marks) Assuming the same tables in 6) and 7), write the PHP code to determine if there is Guitar of which list price is > 2000. 11. (3 marks) Write a PHP regular expression for a postal code. You should consider that the two parts of a postal code can be separated by a space or spaces. 12. (3 marks) Write the PHP code that connects to MySQL on cs.tru.ca. This code should include try-catch and it should print error message there is any error. getCode Functions: setcookie SQL aggregate functions: getFile session_set_cookie_params AVG getLine session_start SUM getTrace session_destroy MIN getTraceAsString session_name MAX session_id COUNT session_write_close session_regenerate_id PDO methods: is_a query property_exists exec method_exists prepare preg_match PDOStatement methods: SQL statements: fetch create table bindValue drop table execute select fetchAll insert into rowCount update closeCursor delete from alter Exception methods: grant getMessage