为什么我的函数返回undefine变量pdo?我尽我所能让它工作,但无济于事。即使我把数据库连接放在同一页面,仍然无法正常工作。可能是什么问题呢 感谢
function referralCount($uid,$reflvl)
{
$stmt= $pdo->query("SELECT * FROM scraffiliateusr WHERE usrinvby='$uid'");
$nusrref1 = $stmt->rowCount();
//$arrusrref1 = $stmt->fetch(PDO::FETCH_LAZY);
$reflvl1=$nusrref1;
$ttlreflvl2="0";
$ttlreflvl3="0";
for ($i=0; $i<$nusrref1; $i++)
{
$arrusrref1 = $stmt->fetch(PDO::FETCH_LAZY);
$stmt= $pdo->query("SELECT * FROM scraffiliateusr WHERE usrinvby='$arrusrref1[0]'");
$nusrref2 = $stmt->rowCount();
//$arrusrref2 = $stmt->fetch(PDO::FETCH_LAZY);
$ttlreflvl2=$ttlreflvl2+$nusrref2;
for ($j=0; $j<$nusrref2; $j++)
{
$arrusrref2 = $stmt->fetch(PDO::FETCH_LAZY);
$stmt= $pdo->query("SELECT * FROM scraffiliateusr WHERE usrinvby='$arrusrref2[0]'");
$nusrref3 = $stmt->rowCount();
//$arrusrref3 = $stmt->fetch(PDO::FETCH_LAZY);
$ttlreflvl3=$ttlreflvl3+$nusrref3;
}
}
$reflvl2=$ttlreflvl2;
$reflvl3=$ttlreflvl3;
if($reflvl=='1')
{
return($reflvl1);
}
elseif($reflvl=='2')
{
return($reflvl2);
}
elseif($reflvl=='3')
{
return($reflvl3);
}
}