我這樣寫也可以返回關(guān)聯(lián)數(shù)組
<?php header('content-type:text/html;charset=utf-8'); error_reporting(E_ALL^E_NOTICE); try?{ $pdo=new?PDO('mysql:host=localhost;dbname=imooc',?'root',?'root'); $sql='SELECT?*?FROM?user'; $stmt=$pdo->prepare($sql); $res=$stmt->execute(); if($res){ while($row=$stmt->fetch(MYSQL_ASSOC)){ print_r($row); echo'<br/>'; } } }catch?(PDOException?$e){ echo?$e->getMessage(); }
2015-12-28
恩 可以的?