I am trying to figure out how to fetch from PDO into my custom class, and in general the PDO-to-object API, and am finding the lack of decent documentation frustrating. Most of the options are only documented as an option, while the examples all use fetching into arrays.
So, can someone explain how these are used:
- PDO::FETCH_OBJ
- PDO::FETCH_CLASS
- PDO::FETCH_CLASSTYPE
- PDO::FETCH_INTO
- PDO::FETCH_LAZY
- PDOStatement::fetch
- PDOStatement::fetchObject
- PDOStatement::setFetchMode
If possible, I would like a general explanation how each function/constant is used for fetching objects, or what the differences are, as well as a specific answer to how do I fetch into my class, e.g. into:
class MyRow {
public $col1, $col2;
}