老師你好,請問我這里怎么加了PDO::FETCH_ASSOC后就沒有東西顯示里,用setfetchmode一樣也沒有東西

小小攻城獅
2014-09-01
3 回答
舉報
0/150
提交
取消
老師你好,請問我這里怎么加了PDO::FETCH_ASSOC后就沒有東西顯示里,用setfetchmode一樣也沒有東西
2014-09-01
舉報
2014-09-02
應該大寫 你試試^_^...
2014-11-04
設置fetchmode,應該放在execute方法的后面吧?
2014-09-01
<?php
$pdo=new PDO('mysql:host=localhost;dbname=test','root','123456');
try{
$sql='select * from user';
$stam=$pdo->prepare($sql);
//var_dump($stam);
$stam->setfetchmode(pdo::fetch_assoc);
$res=$stam->execute();
print_r('<pre>');
$row=$stam->fetchall();
print_r($row);
// if($res){
// while ($row=$stam->setfetchmode()) {
// print_r($row);
// echo '<hr />';
// }
// }
}
catch(pdoexception $e){
echo $e->getmessage();
}