nerdexam
Oracle

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…

Application Development

Question

Examine the content of the employee table:

Now examine this PHP script:

Finally examine this desired output:

Exhibits

1Z0-909 question #46 exhibit 1
1Z0-909 question #46 exhibit 2

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)
  • A
    13% (4)
  • B
    7% (2)
  • C
    73% (22)
  • D
    7% (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 return null.
  • B (FETCH_OBJ) - returns a stdClass object 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

#PDO configuration#Fetch modes#Result handling#Database options

Community Discussion

No community discussion yet for this question.

Full 1Z0-909 Practice