Zend
200-710 · Question #54
200-710 Question #54: Real Exam Question with Answer & Explanation
Sign in or unlock 200-710 to reveal the answer and full explanation for question #54. The question stem and answer options stay visible for context.
Question
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); 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', '[email protected]'); $stmt->execute(); echo "Success!\n"; } catch (PDOException $e) { echo "Failure!\n"; throw $e; }
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); 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', '[email protected]'); $stmt->execute(); echo "Success!\n"; } catch (PDOException $e) { echo "Failure!\n"; throw $e; }
Options
- AThe INSERT will succeed and the user will see the "Success!" message.
- BThe INSERT will fail because of a primary key violation, and the user will see the "Success!" message.
- CThe INSERT will fail because of a primary key violation, and the user will see a PDO warning message.
- DThe INSERT will fail because of a primary key violation, and the user will see the "Failure!" message.
Unlock 200-710 to see the answer
You've previewed enough free 200-710 questions. Unlock 200-710 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.