你写错了.....$tmpSqlArr=array("sql"=>"select id from table where id=1");
$tmpSqlArr=array("sql"=>"select id from table where id=2");
$tmpSqlArr=array("sql"=>"select id from table where id=3"); 改为
$tmpSqlArr[]=array("sql"=>"select id from table where id=1");
$tmpSqlArr[]=array("sql"=>"select id from table where id=2");
$tmpSqlArr[]=array("sql"=>"select id from table where id=3");
不过这样结构也不太好 :0
$tmpSqlArr=array("sql"=>"select id from table where id=2");
$tmpSqlArr=array("sql"=>"select id from table where id=3"); 改为
$tmpSqlArr[]=array("sql"=>"select id from table where id=1");
$tmpSqlArr[]=array("sql"=>"select id from table where id=2");
$tmpSqlArr[]=array("sql"=>"select id from table where id=3");
不过这样结构也不太好 :0
$tmpSqlArr=array("sql"=>"select id from table where id=2");
$tmpSqlArr=array("sql"=>"select id from table where id=3");
有这样写数组的吗??应该这样写:
$db=new PDO(DBCONNSTR,DBUSERID,DBPASSWORD);$tmpSqlArr=array(
0 => "select id from table where id=1",
1 => "select id from table where id=2",
2 => "select id from table where id=3"
);for($i=0;$i <count($tmpSqlArr);$i++)
{
foreach ($db->query($tmpSqlArr[$i]["sql"]) as $row) {
echo "here <br>" ;
}
}楼主这样写,在执行前,$tmpSqlArr的值是:array("sql"=>"select id from table where id=3"); ,前面那些都没有了。
$tmpSqlArr[]=array("sql"=>"select id from table where id=1");
$tmpSqlArr[]=array("sql"=>"select id from table where id=2");
$tmpSqlArr[]=array("sql"=>"select id from table where id=3"); for($i=0;$i <count($tmpSqlArr);$i++)
{
foreach ($db->query($tmpSqlArr[$i]["sql"]) as $row) {
echo "here <br>" ;
}
} 如果count($tmpSqlArr[])=1是可以的,如果大于1就不行了
here<br>
here<br>
here<br>输出完成 (耗时: 0 秒)事实证明.瞎扯蛋.大的于1照样执行.除非数据库查不出东西来.