function readDB($db,$event)
{
try {
$rows = array();
$sql = "SELECT \"Red Score\", \"Blue Score\", red1, red2, red3, blu1, blu2, blu3 FROM Matches WHERE Event='$event' AND Type='Q' ORDER BY Number;";
foreach($db->query($sql) as $row)
{
$rows[] = $row;
echo count($row) . "<br/>";
}
printArray($rows);
} catch(PDOException $e) {
$rows = 'aids';
echo $e->getMessage();
}
$db = null;
}
Run Code Online (Sandbox Code Playgroud)
这是相关的功能.它运行查询并将结果放入2D数组中.更改查询以仅选择一个没有条件的字段仍会返回两件事.
代码返回正确的数据,只是每个记录都是重复的,即一行八行变成16行.在SQLite3控制台中运行时的查询返回一次.
示例:
PHP:
51 51 27 27 836 836 435 435 1102 1102 245 245 88 88 1293 1293
33 33 30 …Run Code Online (Sandbox Code Playgroud)