我尝试在一个php文件中执行多个查询。 第一个查询工作正常,但第二个第三个查询返回一个空数组。
$DB_con = new PDO($dsn, $DB_user, $DB_pass, array(
PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION
));
$sql_sel_sponsoring = $DB_con->prepare('CALL SP_SELECT_SPONSORING(:id)');
$sql_sel_sponsoring->execute(array(':id' => $sponsor));
$sql_res_sponsoring = $sql_sel_sponsoring->fetchAll();
$sql_sel_sponsoring_type = $DB_con->prepare('CALL SP_SELECT_SPONSORING_TYPE()');
$sql_sel_sponsoring_type->execute();
$sql_res_sponsoring_type = $sql_sel_sponsoring_type->fetchAll();
$sql_sel_cbo_members = $DB_con->prepare('CALL SP_SELECT_CBO_MEMBERS()');
$sql_sel_cbo_members->execute();
$sql_res_cbo_members = $sql_sel_cbo_members->fetchAll();
使用vardump()我有不同的对象
var_dump($sql_sel_sponsoring);
var_dump($sql_sel_sponsoring_type);
var_dump($sql_sel_cbo_members);
结果
object(PDOStatement)#6(1){[" queryString"] => string(30)" CALL SP_SELECT_SPONSORING(:id)" }
object(PDOStatement)#7(1){[" queryString"] => string(32)" CALL SP_SELECT_SPONSORING_TYPE()" }
object(PDOStatement)#8(1){[" queryString"] => string(28)" CALL SP_SELECT_CBO_MEMBERS()" }
但是3个结果集中有2个是空的
print_r($sql_res_sponsoring);
print_r($sql_res_sponsoring_type);
print_r($sql_res_cbo_members);
,并提供:
数组([0] =>数组([SID_SPONSORING] => 70 [0] => 70 [SID_SPONSOR] => 88 [1] => 88 [Jaar] => 2014 [2 ] => 2014 [Bedrag] => 60.00 [3] => 60.00 [Omschrijving] => Publiciteitsboekje脚跟A5 [4] => Publiciteitsboekje脚跟A5)) 数组() Array()
我怎样才能让它发挥作用?