这是我的sql语句
SELECT TOWN_ID FROM TOWN WHERE CITY_ID = 1
输出为:4,5,6,7,67,887
在php中我的代码是这样的:
$temp = 1;
$sql = "SELECT TOWN_ID FROM TOWN WHERE CITY_ID = 1 = $temp";
$compiled = oci_parse($conn, $sql);
oci_execute($compiled);
$row = oci_fetch_array($compiled, OCI_ASSOC+OCI_RETURN_LOBS);
foreach ($row as $element )
{
echo "\n".$element."\n";
}
我的输出只有4,如何获得其他输出?
答案 0 :(得分:2)
从manual:返回查询中的下一行作为关联或数字数组
您需要在循环中调用此函数以获取所有记录:
while ($row = oci_fetch_array($compiled, OCI_ASSOC+OCI_RETURN_LOBS))
{
foreach ($row as $element )
{
echo "\n".$element."\n";
}
}