我在下面创建了这段代码,但它返回字符串,我只需要数字ID。
$result7 = "SELECT b.id from boleto b where b.bol_nn = 0 and b.codigo = ".$terceiro." order by b.id";
$sql7 = $db->SetFetchMode(ADODB_FETCH_NUM);
$sql7 = $db->Execute("$result7");
foreach ($sql7 as $row) {
print_r($row);
}
/*
Array ( [0] => 538119 ) Array ( [0] => 538120 ) Array ( [0] => 538121 ) Array ( [0] => 538122 ) Array ( [0] => 538123 ) Array ( [0] => 538124 ) Array ( [0] => 538125 ) Array ( [0] => 538126 ) Array ( [0] => 538127 ) Array ( [0] => 538128 ) Array ( [0] => 538129 ) Array ( [0] => 538130 )
*/
但我想要一个只有id的数组列表。
538119
538120
538121 ...
答案 0 :(得分:1)
或者有一个更简单的解决方案:
$result7 = "SELECT b.id from boleto b where b.bol_nn = 0 and b.codigo = ".$terceiro." order by b.id";
$sql7 = $db->SetFetchMode(ADODB_FETCH_NUM);
$sql7 = $db->Execute("$result7");
foreach ($sql7 as $row) {
$ids[] = $row[0]; // Only this line had changed
}
print_r($ids);
答案 1 :(得分:0)
$sqlresult = $sql7->Fields(0);
通过执行
检索Recordset后