如何将mysql_fetch_assoc转换为PDO?

时间:2013-07-23 01:17:27

标签: mysql pdo

$result = $db->("SELECT `count` FROM playerCount");
while($row = mysql_fetch_assoc($result)) {
      echo $row['count'];
}

我该如何转换行: while($ row = mysql_fetch_assoc($ result)){

到PDO?

感谢。

1 个答案:

答案 0 :(得分:4)

$stmt = $db->query(...);
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {