【发布时间】:2019-09-21 09:29:52
【问题描述】:
mysql
select distinct(cat) from code order by cat asc;
结果 - 选择了 1 行
确实如此 - 因为整个 cat 列具有相同的值。
php
$st = $db->query("select distinct(cat) from code order by cat asc");
$st->execute();
$arr = $st->fetch();
echo count($arr); // 2
为什么我使用 php 选择了两行?
【问题讨论】:
-
我认为,fetch() 将关联和索引的结果一起返回
-
您很可能也可以删除
$st->execute()部分。$st变量应该已经包含结果。