200-710 Exam QuestionsBrowse all questions from this exam

200-710 Exam - Question 21


Consider the following table data and PHP code. What is the outcome?

Table data (table name "users" with primary key "id"):

PHP code (assume the PDO connection is correctly established):

Show Answer
Correct Answer: B,D

The provided PHP code attempts to insert a new row into the 'users' table with the primary key value '1', which already exists in the table. Since 'id' is a primary key, this action will result in a primary key violation. Upon encountering this violation, the PDOException will be caught by the catch block, where it will echo 'Failure!' and subsequently throw the exception. Hence, the user will see the 'Failure!' message.

Discussion

2 comments
Sign in to comment
sjranjanOption: D
Sep 30, 2021

The correct answer is D

gaddour_medOption: B
Apr 26, 2022

B is correct execute() return true on success and false on error. no need of try catch.