Amit Dhamu

Writes Code

Query Fetch Types in PDO

// Returns an array indexed by column name
PDO::FETCH_ASSOC 

// Returns an array indexed by both column name and number
PDO::FETCH_BOTH (default)

// Assigns the values of your columns to the variables set with the ->bindColumn() method
PDO::FETCH_BOUND 

// Assigns the values of your columns to properties of the named class
// It will create the properties if matching properties do not exist
PDO::FETCH_CLASS

// Updates an existing instance of the named class
PDO::FETCH_INTO 

// Combines PDO::FETCH_BOTH/PDO::FETCH_OBJ
// Creates object variable names as they are used
PDO::FETCH_LAZY

// Returns an array indexed by column number
PDO::FETCH_NUM

// Returns an anonymous object with property names that correspond to the column names
PDO::FETCH_OBJ 


Interpolated from Nettuts+.


fetch types / arrays / associative / pdo

← PDO Database Connection Simple Select Query with PDO →