以下是我的代码的结果:
$res = $stm->fetchAll();
/*
Array
(
[0] => Array
(
[name] => apple
[0] => apple
[colour] => red
[1] => red
)
[1] => Array
(
[name] => pear
[0] => pear
[colour] => green
[1] => green
)
)
如果我使用fetchAll(PDO::FETCH_ASSOC)
,结果将是:
/*
Array
(
[0] => Array
(
[name] => apple
[colour] => red
)
[1] => Array
(
[name] => pear
[colour] => green
)
)
现在我想知道,我怎么能得到这个?
/*
Array
(
[0] => Array
(
[0] => apple
[1] => red
)
[1] => Array
(
[0] => pear
[1] => green
)
)
注意PDO::FETCH_COLUMN
不会返回预期结果。