小小攻城狮
2014-09-01 23:50
老师你好,请问我这里怎么加了PDO::FETCH_ASSOC后就没有东西显示里,用setfetchmode一样也没有东西
应该大写 你试试^_^...
设置fetchmode,应该放在execute方法的后面吧?
<?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();
}
PDO—数据库抽象层
30045 学习 · 418 问题
相似问题