note 65551 deleted from function.pdostatement-fetchall by bjori
| From: | bjori@php.net | Date: | Wed, 03 May 2006 09:18:29 +0000 |
| Subject: | note 65551 deleted from function.pdostatement-fetchall by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-110436@lists.php.net to get a copy of this message | ||
Note Submitter: dozoyousan at gmail dot com
----
When you set return object name, PDO::FETCH_CLASS use.
$pdo = new PDO( $dsn, $user, $pass );
$sql = " SELECT key,value FROM hoge ";
$stmtObj = $pdo->query( $sql );
$rowObjs = $stmtObj->fetchAll(PDO::FETCH_CLASS,'otherClass');
class otherClass
{
・・・・
}
print_r( $rowObjs );
result:
Array
(
[0] => otherClass Object
(
[key] => ・・・・
[value] => ・・・・
)
[1] => otherClass Object
(
[key] => ・・・・
[value] => ・・・・
)