我正在使用PEAR's PDO library
来获取我需要的结果。
虽然我知道我可以在结果出现时手动重建数组,但我想知道是否有一个我错过的内部函数,当我直接从DB
获取结果时可能会这样做?
目前:
function get($query){
$affected =& $this->conn->query($query);
// Always check that result is not an error
if (PEAR::isError($affected)) {
die($affected->getMessage());
}
$res = $affected->fetchAll();
return $res;
}
返回
[sexnumbers] => Array
(
[0] => Array
(
[sex] => 1
[no] => 35
)
[1] => Array
(
[sex] => 2
[no] => 17
)
[2] => Array
(
[sex] => 3
[no] => 3
)
)
通缉结果集
[sexnumbers] => Array
(
[sex] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
[no] => Array
(
[0] => 35
[1] => 17
[2] => 3
)
)