(no version information, might be only in CVS)
PDOStatement::fetch -- Fetches the next row from a result setWarning |
This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk. |
Fetches a row from a result set associated with a PDOStatement object.
fetch_style can be one of the following values:
PDO_FETCH_ASSOC: returns an array indexed by column name as returned in your result set
PDO_FETCH_BOTH (default): returns an array indexed by both column name and column number as returned in your result set
PDO_FETCH_BOUND: returns TRUE and assigns the values of the columns in your result set to the PHP variables to which they were bound with the PDO::bindParam() method
PDO_FETCH_LAZY: combines PDO_FETCH_BOTH and PDO_FETCH_OBJ, creating the object variable names as they are accessed
PDO_FETCH_OBJ: returns an anonymous object with property names that correspond to the column names returned in your result set
PDO_FETCH_NUM: returns an array indexed by column number as returned in your result set, starting at column 0
The above example will output:
PDO_FETCH_ASSOC: Return next row as an array indexed by column name Array ( [NAME] => apple [COLOUR] => red ) PDO_FETCH_BOTH: Return next row as an array indexed by both column name and number Array ( [NAME] => banana [0] => banana [COLOUR] => yellow [1] => yellow ) PDO_FETCH_LAZY: Return next row as an anonymous object with column names as properties PDORow Object ( [NAME] => orange [COLOUR] => orange ) PDO_FETCH_OBJ: Return next row as an anonymous object with column names as properties kiwi |