nerdexam
Zend

200-710 · Question #55

QUESTION 58 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 [email protected] 2…

The correct answer is C. The value of $row is array(0 => 'anna', 'name' => 'anna', 1 => '[email protected]', 'email' => '[email protected]'). See the full explanation below for the reasoning.

Databases & SQL

Question

QUESTION 58 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 [email protected] 2 betty [email protected] 3 clara [email protected] 5 sue [email protected] 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];

Options

How the community answered

(36 responses)
  • A
    6% (2)
  • B
    6% (2)
  • C
    86% (31)
  • D
    3% (1)

Topics

#PDO#fetchAll#FETCH_BOTH#result sets

Community Discussion

No community discussion yet for this question.

Full 200-710 Practice