当我在fetch while循环之外执行retrieveSubcategory()时,它可以工作,但是从它内部返回false。
private function retrieveSubcategory($subcategory_ID){
global $db;
Subcategory = $db->query("SELECT subcategory_NL FROM wyby_subcategory WHERE subcategory_ID=$subcategory_ID");
echo '<pre>' , var_dump($Subcategory) ,'</pre>'; //returns false Why?
$Subcategory = $Subcategory->fetch_object();
return $Subcategory->subcategory_NL;
}
function RetrieveAllSubcat($CompID)
{
$cats ="";
global $database;
$query = "SELECT DISTINCT(subcategory_ID) AS subcategory_ID FROM wyby_product WHERE company_ID=? ORDER BY subcategory_ID ASC";
$ResultQuery = $db->prepare($queryString);
$ResultQuery->bind_param('s',$Param);
$ResultQuery->execute();
$ProductQuery->bind_result($subcategory_ID);
while($ProductQuery->fetch()){
$cats .= " ". $this->retrieveSubcategory($subcategory_ID) .",";
}
echo $cats;
}