我有下面的代码:的foreach在PHP类返回仅1结果
Example.class.php
class Example {
public function functionArrayExample() {
$query = array();
// this foreach comes from a select that returns more than 1 results
foreach($someSelect as $exAS) {
$query[] = $exAS;
}
return $query;
}
}
的index.php
require_once("Example.class.php");
$example = new Example();
$selectExample = $example -> functionArrayExample();
die(var_dump($selectExample));
但是,只显示1个结果(在数组中)(在die()
一行),为什么?由于查询返回多于1个结果?
你能告诉我们SELECT语句以及它是如何用于给出'$ someSelect'数组的吗? – Niols
你需要指定'$ someSelect'变量是什么,因为这个例子不是很明显。 – Jakuje
你也可以发布你如何从查询中检索行的代码? –