LIS4381 assignment questions a1-a3

Ace your homework & exams now with Quizwiz!

The ____ keyword specifies the name of the table that needs to be modified when updating records.

UPDATE

To store text in an address field, you specify a data type of ____ because the amount of storage space allocated will vary depending upon the number of characters in the field.

VARCHAR

You can specify which records to return from a database by using the ____ clause.

WHERE

Which of the following is NOT part of an HTTP URL: a. node b. path c. filename d. protocol

a. node

If a row in one table is related to just one row in another table, the tables are said to have a a. one-to-one relationship b. unary relationship c. many-to-many relationship d. one-to-many relationship

a. one-to-one relationship

To perform a reverse sort on query results from a SELECT statement, add the ___ keyword after the name of the field by which you want to perform the sort.

DESC

When the web server recieves an HTTP request for a PHP page, the web server calls the a. web browser b. static web page c. database server d. PHP interpreter

d. PHP interpreter

What does routine 1 store in the variable named $category_name? a. An array of the category names in the categories table b. The category name for the row in categories table that has a category ID of 1 c. The category name for the first row in the categories table of the database d. The category name for the row in categories table that corresponds to the value in $category_id

d. The category name for the row in categories table that corresponds to the value in $category_id

To view the source code for a web page in the Firefox or IE browser, you can select the appropriate command from the a. Source menu b. File menu c. Tools menu d. View menu

d. View menu

What does this function return when it is called?

d. an array of the columns in the row with the specified product ID

When you use the MVC pattern, the model consists of the PHP files that work with and represent the _________________________ of the application.

d. data or database

What does a relational database use to uniquely identify each row in a table? a. non-primary keys b. foreign keys c. indexes d. primary keys

d. primary keys

Which of the following can a SELECT statement not do to the data in a table? a. Delete the rows b. List selected columns c. Get selected rows d. Sort the rows

a. Delete the rows

An error that occurs after an application is running is known as a

a. runtime error

The column definition for a MySQL table can be used to determine all but one of the following. Which one is it? a. what range of values the column can contain b. whether the column has a default value c. what type of data the column can contain d. whether the column can contain a null value

a. what range of values the column can contain

To pass data back to the statement that calls a function, the function can use the _________________________ statement.

c. return

To run a PHP application that has been deployed on your own computer, you can enter a URL in the address bar of your browser that a. specifies just the application root directory b. uses apache as the domain name c. uses localhost as the domain name d. specifies just the application root directory and the starting filename

c. uses localhost as the domain name

In a conditional expression that includes logical operators, the AND operator has a lower order of precedence than the ______________ operator.

NOT

You use the ___ statement to retrieve records from a table.

SELECT

You create line comments in PHP code by adding to a line you want to use as a comment. (Choose all that apply.)

# //

PHP variables begin with _____.

$

Block comments begin with /* and end with _____.

*/

In PHP, the concatenation operator is

.

How many times will the while loop that follows be executed? $months = 5; $i = 1; while ($i > $months) { $futureValue = $futureValue * (1 + $monthlyInterestRate); $i = $i+1; }

0

SELECT vendorName, invoiceNumber, invoiceDate, invoiceTotal FROM vendors Inner Join invoices On vendors.vendorID = invoices.vendorID WHERE invoiceTotal >= 500 ORDER BY vendorName DESC How many columns will the result set have?

4

After the if statement that follows is executed, what will the value of $discountAmount be? $discount_amount; $order_total = 200; if ($order_total > 200) { $discount_amount = $order_total * .3; } else if ($order_total > 100) { $discount_amount = $order_total * .2; } else { $discount_amount = $order_total * .1; }

40

____ a variable is the processing of assigning a first value to a variable at the time of creation.

Initializing

You can arrange query results from a SELECT statement using the keyword(s) ____.

ORDER BY

The goal of debugging is to

a. fix all errors in the application

SELECT vendorName, invoiceNumber, invoiceDate, invoiceTotal FROM vendors Inner Join invoices On vendors.vendorID = invoices.vendorID WHERE invoiceTotal >= 500 ORDER BY vendorName DESC What table(s) does the data in the result set come from? a. vendors and invoices b. vendorName and invoiceNumber c. vendors d. invoices

a. vendors and invoices

The first statement in this example gets and runs a file named database.php. What must this code do for the rest of the statements in this example to work? a. Create a PDO object named $db-> that connects to the right database b. Create a PDOStatement object named $db-> that connects to the right database c. Create a PDO object named $db that connects to the right database d. Create a PDOStatement object named $db that connects to the right database

c. Create a PDO object named $db that connects to the right database

When you use the header function to redirect a request,

c. a response is returned to the browser that tells it to request another page

The result set retrieved by the following SELECT statement contains rows that have SELECT balance, number FROM accounts WHERE balance < 0 a. all of the columns from the accounts table where balance is less than 0 b. all of the columns from the accounts table c. two of the rows from the account table d. two of the columns from the accounts table where balance is less than 0

d. two of the columns from the accounts table where balance is less than 0

When you use the MVC pattern, the ___________________ consists of the PHP files that make up the user interface of the application.

d. view

Which of the following is not a benefit of using the MVC pattern for an application?

e. the application runs more efficiently

A(n) ____ operator requires a single operand either before or after the operator.

unary

A variable name in PHP can only contain letters, numbers, and _____.

underscores

Assignment operators are used to assign a ____ to a variable.

value

What will the variable $name contain after the code that follows is executed? $first_name = 'Bob'; $last_name = 'Roberts'; $name = "Name: $first_name";

Name: Bob

Which of the following is the correct way to code a PHP statement that executes an INSERT, UPDATE, or DELETE statement that's stored in $statement if the PDO object is $db? a. $modify_count = $db->exec($statement); b. $modify_count = exec->$db($statement); c. $modify_count = $db->query($statement); d. $modify_count = query->$db($statement);

a. $modify_count = $db->exec($statement);

When you code a function in PHP, you start with the keyword __________________.

a. function

A PHP variable name a. is case-sensitive b. can be a PHP reserved word c. can start with a letter, a digit, or two underscores d. can contain special characters

a. is case-sensitive

To round and format the value of a variable named $number to 3 decimal places and store it in a variable named $number_formatted, you code a. $number_formatted = format_number($number, 3); b. $number_formatted = number_format($number, 3, round); c. $number_formatted = format_number($number, 3, round); d. $number_formatted = number_format($number, 3);

d. $number_formatted = number_format($number, 3);

Which of the following is the correct way to code a PHP statement that puts the first row of PDOStatement object named $products in an array named $product? a. $product = $products->query(); b. $product = $db->fetch($products); c. $product = $db->query($products); d. $product = $products->fetch();

d. $product = $products->fetch();

When you create a function definition (i.e., code a function) in PHP, you can list one or more ____________________ separated by commas (if more than one), and wrapped within parentheses.

d. parameters

An error that violates the rules for how PHP statements must be written is known as a

d. syntax error

When you use the MVC pattern, the controller gets the HTTP requests and then

d. the model and the view

Which of the following is a proper PHP statement for calling the function in this example and storing the returned result in a variable named $product.

a. $product = get_product($product_id);

Which of the following is the correct way to code a PHP statement that returns the result set for a SELECT statement that's stored in $statement if the PDO object is $db? a. $results = $db->query($statement); b. $results = query->$db($statement); c. $results = exec->$db($statement); d. $results = $db->exec($statement);

a. $results = $db->query($statement);

In the catch block of a try/catch statement for handling PDO exceptions, you can get a message that describes the exception by using the getMessage method of the a. PDOException object b. PDOStatement object c. Result set array d. PDO object

a. PDOException object

When you create a PDO object, you have to pass all but one of these arguments to it: Which one is it? a. Server name b. User name c. Data source name d. Password

a. Server name

When you code a DELETE or an UPDATE statement, you usually need to include a. a WHERE clause b. an inner join c. an outer join d. a SORT BY clause

a. a WHERE clause

In the code that follows, if $error_message isn't empty if ($error_message != '') { include('index.php'); exit(); } a. control is passed to a page named index.php that's in the current directory b. control is passed to a page named index.php that's in the parent directory c. nothing happens because the condition is false d. control is passed to a page named index.php that's in the child directory

a. control is passed to a page named index.php that's in the current directory

When you use the MVC pattern, you

a. make each layer as independent as possible

A join that returns records from related tables only if their related fields match is called a. a data join b. an inner join c. a cross join d. an outer join

b. an inner join

To call a function in PHP, you code the function name followed by a list of any _________________________ that are required.

b. arguments

A web application is a type of a. client-side application b. client/server application c. database application d. server-side application

b. client/server application

The goal of testing is to

b. find all errors in the application

When you code an INSERT statement, you don't have to include the data for a column that a. does not allow null values b. has a default value c. is a primary key d. is a foreign key

b. has a default value

One reason for using the header() function to redirect a request, rather than using the include() or require() functions

b. is to have a PHP file run itself again

What does routine 2 store in the variable named $products? a. A PDOStatement object for the columns in the first row in the products table b. A PDOStatement object for the rows in the products table that have a category ID equal to 1 c. A PDOStatement object for the rows in the products table that have a category ID equal to the value in $category_id d. A PDOStatement object for all rows in the products table

c. A PDOStatement object for the rows in the products table that have a category ID equal to the value in $category_id

If a URL specifies a directory that doesn't contain a default page, Apache displays a. a list of the PHP applications in that directory b. an error message c. a list of all of the directories in that directory d. a list of all of the web applications in that directory

c. a list of all of the directories in that directory

SELECT vendorName, invoiceNumber, invoiceDate, invoiceTotal FROM vendors Inner Join invoices On vendors.vendorID = invoices.vendorID WHERE invoiceTotal >= 500 ORDER BY vendorName DESC If vendorName contains string data and invoiceTotal contains decimal values, how will the result set be ordered? a. alphabetically starting with A b. numerically starting with 0 c. alphabetically starting with Z d. numerically starting with 500

c. alphabetically starting with Z

A simple way to trace the execution of an application is to insert __________________ statements at appropriate points within the code.

c. echo

What does a relational database use in the child tables to relate to the primary keys in the parent tables? a. primary keys b. indexes c. foreign keys d. non-primary keys

c. foreign keys

The HTTP response for a dynamic web page is passed a. from PHP to the browser b. from the database server to the web server c. from the web server to the browser d. from the web server to PHP

c. from the web server to the browser

An error that lets the application run but produces the wrong results is known as a

c. logic error


Related study sets

CCNA4 Chapter 7 Network Evolution

View Set

sociology 101 - chapter 14; marriage and family

View Set

"La gran aventura de alejandro" English translation chapters 8-15

View Set

Retirement and other insurance concepts-Practice Questions

View Set

Practice labeling pathos, logos, and ethos.

View Set

Mineral properties and Identification

View Set

American History Imperialism - Smock

View Set