PHP » GoLang |
login |
register |
about
|
GoLang PDOStatement::fetch
request it (504)
GoLang replacement for PHP's PDOStatement::fetch
[edit | history]
PDOStatement::fetch(PHP 5 >= 5.1.0, PHP 7, PECL pdo >= 0.1.0) PDOStatement::fetch — Fetches the next row from a result set Description
public mixed PDOStatement::fetch
([ int
$fetch_style
[, int $cursor_orientation = PDO::FETCH_ORI_NEXT
[, int $cursor_offset = 0
]]] )
Fetches a row from a result set associated with a PDOStatement object. The
Parameters
Return Values
The return value of this function on success depends on the fetch type. In
all cases, Examples
Example #1 Fetching rows using different fetch styles
<?php 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 Example #2 Fetching rows with a scrollable cursor
<?php The above example will output: Reading forwards: 21 10 5 16 0 5 19 20 10 Reading backwards: 19 20 10 16 0 5 21 10 5 Example #3 Construction order When objects are fetched via PDO::FETCH_CLASS the object properties are assigned first, and then the constructor of the class is invoked. If PDO::FETCH_PROPS_LATE is also given, this order is reversed, i.e. first the constructor is called, and afterwards the properties are assigned.
<?php The above example will output something similar to: I am Alice. I am Alice. I don't have a name yet. I am Bob. See Also
|
more
Recently updated
more
Most requested
more
Last requests
|