Web Application Programming Question 1 Which method of a PHP Data Object can be
ID: 3902128 • Letter: W
Question
Web Application Programming
Question 1
Which method of a PHP Data Object can be used to execute INSERT, UPDATE, and DELETE statements?
Question options:
return
data
action
exec
query
Which PHP class can be used to connect to a MySQL database?
Question options:
db
DataConnect
SelectData
argument
PDO
When INSERT, UPDATE, or DELETE statements are used in conjunction with a PHP Data Object, what is returned?
Question options:
success or failure
the number of columns that were affected
true or false
the number of rows that were affected
the number of tables that were affected
Which clause in a SQL statement specifies the table(s) that should supply the data that is returned?
Question options:
JOIN
SELECT
WHERE
ORDER BY
FROM
When coding relative URLs, you can begin the URL with a(n) ____________ to indicate that the URL should start with the current directory.
Question options:
colon (:)
dollar sign ($)
question mark (?)
single dot (.)
exclamation point (!)
The material on which this question is based on can be found on page 157 of the textbook.
Which clause in a SQL statement specifies the columns to return?
Question options:
JOIN
ORDER BY
WHERE
FROM
SELECT
Web Application Programming
Question 1
Explanation / Answer
1. exec
Explanation:
A sample code to insert data is given below.
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";
// use exec() because no results are returned
$conn->exec($sql);
echo "New record created successfully";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
3. PDO
Explanation: This is how we connect to DB using PDO
<?php
$servername = "localhost";
$username = "username";
$password = "password";
try {
$conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>
4. the number of rows that were affected
Explanation:
SQL insertion, update or delete query always returns the number of rows affected.
10. FROM
Explanation:
FROM is used to select the list of tables from which data needs to be fetched.
11. colon(:)
Explanation:
Self explanatory.
12. SELECT
Explanation:
SELECT is used to mention the columns for which data need to be fetched.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.