Exam 200-710 All QuestionsBrowse all questions from this 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):

    Correct Answer: 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
sjranjanOption: D

The correct answer is D

gaddour_medOption: B

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