5

对于此查询: $sql='select col from table where other_col=?';

我目前正在获取返回的数据,如下所示: $data=$statement->fetch()['col'];

这对我来说看起来不太好。有没有更好的方法来做到这一点,或者就这样好吗?

4

1 回答 1

13

你可以试试 :

$data=$statement->fetchColumn(0);
于 2012-06-27T11:16:40.310 回答