FETCH Modes

FETCH Modes

これまで見てきた章でわかるとおり、PDO::query を使って、データーベースから情報を取り出してこれることがわかったと思う。PDO::queryのメソッドは次の結果を返す。すなわち、一つのPDOStatementオブジェクトである。それらはmysql_fetch_object() や pg_fetch_object() の中で利用されるのと、同じように利用されるのである。もちろん、次のようなこともよくおこる。すなわち、数値インデックスが必要だったり、あるいは連想配列的なインデックスが必要だったりである。PDO::queryは次のものも提供する。その方法はすなわち、コーダーに次のことを許可するのである。具体的には、PDOStatement オブジェクト経由またはPDOStatement::setFetchMode()経由でfetchモードをセットすることができるというものである。

The section above showed how using PDO::query we can fetch information from the database. The PDO::query method returns a PDOStatement object that can be utilized in much the same was as mysql_fetch_object() or pg_fetch_object(). Of course there are times when an numerical index is needed or an associative index. PDO::query provides for this also by allowing the coder to set the fetch mode for via the PDOStatement object or via PDOStatement::setFetchMode().

http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.html#8

~ by n2t81u4bzzqhzfo : 2009年 2月 4日.

コメントを残す