What is the outcome?
Consider the following table data and PHP code. What is the outcome? Table data (table
name “users” with primary key “id”): id name email ——- ———– ——————- 1 anna
alpha@example.com 2 betty beta@example.org 3 clara gamma@example.net 5 sue
sigma@example.info PHP code (assume the PDO connection is correctly established):
$dsn = ‘mysql:host=localhost;dbname=exam’; $user = ‘username’; $pass = ‘********’; $pdo =
new PDO($dsn, $user, $pass); try { $cmd = “INSERT INTO users (id, name, email)
VALUES (:id, :name, :email)”; $stmt = $pdo->prepare($cmd); $stmt->bindValue(‘id’, 1);
$stmt->bindValue(‘name’, ‘anna’); $stmt->bindValue(’email’, ‘alpha@example.com’);
$stmt->execute(); echo “Success!”; } catch (PDOException $e) { echo “Failure!”; throw $e; }
What is a possible outcome?
Consider the following table data and PHP code. What is a possible outcome? Table data
(table name “users” with primary key “id”): id name email ——- ———– ——————- 1
anna alpha@example.com 2 betty beta@example.org 3 clara gamma@example.net 5 sue
sigma@example.info PHP code (assume the PDO connection is correctly established):
$dsn = ‘mysql:host=localhost;dbname=exam’; $user = ‘username’; $pass = ‘********’; $pdo =
new PDO($dsn, $user, $pass); $cmd = “SELECT name, email FROM users LIMIT 1”; $stmt
= $pdo->prepare($cmd); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_BOTH);
$row = $result[0];
What is the outcome?
Consider the following table data and PHP code, and assume that the database supports
transactions. What is the outcome? Table data (table name “users” with primary key “id”): id
name email ——- ———– ——————- 1 anna alpha@example.com 2 betty
beta@example.org 3 clara gamma@example.net 5 sue sigma@example.info PHP code
(assume the PDO connection is correctly established): $dsn =
‘mysql:host=localhost;dbname=exam’; $user = ‘username’; $pass = ‘********’; $pdo = new
PDO($dsn, $user, $pass); try { $pdo->exec(“INSERT INTO users (id, name, email)
VALUES (6, ‘bill’, ‘delta@example.com’)”); $pdo->begin(); $pdo->exec(“INSERT INTO users
(id, name, email) VALUES (7, ‘john’, ‘epsilon@example.com’)”); throw new Exception(); }
catch (Exception $e) { $pdo->rollBack(); }
which sample shows how to convert the value to JSON?
Given a PHP value, which sample shows how to convert the value to JSON?
which code sample correctly indicates how to decode the string to native PHP values?
Given a JSON-encoded string, which code sample correctly indicates how to decode the
string to native PHP values?
Which of the following PHP values may NOT be encoded to a JavaScript literal using PHP’s ext/json capabi
Which of the following PHP values may NOT be encoded to a JavaScript literal using PHP’s
ext/json capabilities?
Which of the following will NOT instantiate a DateTime object with the current timestamp?
Which of the following will NOT instantiate a DateTime object with the current timestamp?
which of the following samples will correctly return a date in the format ‘2014-01-01 00:00:01’?
Given a DateTime object that is set to the first second of the year 2014, which of the
following samples will correctly return a date in the format ‘2014-01-01 00:00:01’?
what can you use to compare the two dates and indicate that $date2 is the later of the two dates?
Given the following DateTime objects, what can you use to compare the two dates and
indicate that $date2 is the later of the two dates? $date1 = new DateTime(‘2014-02-03’);
$date2 = new DateTime(‘2014-03-02’);
which sample will NOT alter the date to the value ‘2014-02-15’?
Given the following DateTime object, which sample will NOT alter the date to the value
‘2014-02-15’? $date = new DateTime(‘2014-03-15’);