PDOFETCHBOTH
PDOFETCHBOTH, or PDO::FETCH_BOTH, is a fetch mode in PHP's PDO extension used with PDOStatement::fetch or fetchAll. When this mode is selected, each row is returned as an array that can be accessed using both numeric column indices and the column names.
In a result set, numeric indices start at 0 and reflect the order of the selected columns.
Default behavior: FETCH_BOTH is the default fetch mode for PDOStatement::fetch unless the mode is explicitly changed,
Usage considerations: If you only need numeric indices, FETCH_NUM can be more memory-efficient. If you only need
Example: $stmt = $pdo->query("SELECT id, name FROM users"); $row = $stmt->fetch(PDO::FETCH_BOTH); echo $row[0]; echo $row['name'];
Related modes include PDO::FETCH_ASSOC, PDO::FETCH_NUM, and PDO::FETCH_OBJ.