Created
March 26, 2012 16:44
-
-
Save hirak/2206420 to your computer and use it in GitHub Desktop.
PDOで1xNのデータをDBから取得するなら ref: http://qiita.com/items/856c4bac914451bc0c75
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$pdo = new PDO('...'); | |
$stmt = $pdo->query('SELECT txt FROM Hoge'); | |
var_dump($stmt->fetchAll(PDO::FETCH_NUM)); | |
//[ [txt1], [txt2], [txt3], ... ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$stmt = $pdo->query('SELECT txt FROM Hoge'); | |
var_dump($stmt->fetchAll(PDO::FETCH_COLUMN, 0)); | |
//[ txt1, txt2, txt3, ... ] | |
//こうしてもOK | |
$stmt = $pdo->query('SELECT txt FROM Hoge'); | |
$stmt->setFetchMode(PDO::FETCH_COLUMN, 0); | |
var_dump($stmt->fetchAll()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment