1Z0-909 · Question #46
Examine the content of the employee table: Now examine this PHP script: Finally examine this desired output:
The correct answer is C. $options = [PDO:: ATTR_DEFAOLT_FETCH__MODE => PDO : : FETCH_BOTH]. PDO::FETCH_BOTH is the correct fetch mode when the desired output shows data accessible by both numeric index (e.g., $row[0]) and associative key (e.g., $row['name']) simultaneously - it is also PDO's default fetch behavior, making it the natural fit for scripts that rely on…
Question
Examine the content of the employee table:
Now examine this PHP script:
Finally examine this desired output:
Exhibits
Options
- A$options = [PDO:: ATTR_DEFAULT_FETCH__MODE => PDO: : FETCH_ASSOC] ;
- B$options = [PDO:: ATTR_DEFAUXT_FETCH__MODE => PDO: : PDO: :FETCH_OBJ] ;
- C$options = [PDO:: ATTR_DEFAOLT_FETCH__MODE => PDO : : FETCH_BOTH] ;
- D$options = [PDO:: ATTR__DEFAULT_FETCH MODE => PDO: :FETCH_CLASS] ;
How the community answered
(30 responses)- A13% (4)
- B7% (2)
- C73% (22)
- D7% (2)
Explanation
PDO::FETCH_BOTH is the correct fetch mode when the desired output shows data accessible by both numeric index (e.g., $row[0]) and associative key (e.g., $row['name']) simultaneously - it is also PDO's default fetch behavior, making it the natural fit for scripts that rely on either access pattern.
Why the distractors fail:
- A (
FETCH_ASSOC) - returns only named/string keys; numeric index access like$row[0]would returnnull. - B (
FETCH_OBJ) - returns astdClassobject with properties ($row->name), not an array at all. - D (
FETCH_CLASS) - maps rows into a user-defined class and requires a class name argument; it cannot be used as a standalone default mode without specifying the target class.
Memory tip: The word "BOTH" tells you exactly what you get - both array styles at once. If you see output using two different ways to access the same row data, reach for
FETCH_BOTH.
Topics
Community Discussion
No community discussion yet for this question.

