我正在使用PHP PDO,并让它返回一个关联数组。
我可以循环遍历PDO创建的关联数组,但是我不知道如何从函数中返回该数组。
我很新手 PHP 和 PDO,希望得到任何帮助。
我可以循环遍历PDO创建的关联数组,但是我不知道如何从函数中返回该数组。
function wantedrentals($provence, $country, $dbh)
{
echo "Now in wanted wanted rentals function<br><br>";
$journeyrentalssarray = array();
$sth = $dbh->query("SELECT summary, url, provence, country from tblAccomadation WHERE country = $country ");
# setting the fetch mode
$sth->setFetchMode(PDO::FETCH_ASSOC);
while($row = $sth->fetch())
{
echo $row['summary'] . "\n";
echo $row['url'] . "\n";
echo $row['provence'] . "\n";
echo $row['country'] . "\n";
}
return $journeyrentalssarray;
}
我很新手 PHP 和 PDO,希望得到任何帮助。
var_dump( $row );
得到了什么? - Prafulla Kumar Sahu