如何在oopphp中一次将所有结果行返回给其他类函数


how to return all the resulted rows to other class function at one time in oop php?

当我在其他页面上返回此函数时,我只得到一个结果行关于面向对象php中的数组,请帮助我&thanx。

  function select($query)
  {          
         // echo $query."<br>";  
         $this->slct_result= mysqli_query($this->conn,$query);       
         while($this->array_row = $this->slct_result->fetch_assoc())
         {             
            $this->get_cat= $this->array_row['cat_name'];       
            print_r($this->get_cat);
            return $this->get_cat;
         }
     }      
function select($query)
{          
    // echo $query."<br>";  
    $this->slct_result= mysqli_query($this->conn,$query); 
    $result = array();
    while($this->array_row = $this->slct_result->fetch_assoc())
    {             
        $this->get_cat= $this->array_row['cat_name'];       
        array_push($result, $this->get_cat);
    }
    return $result;
}

然后,从你在其他代码中做的任何事情:

$queryResult = select("QUERY");
foreach ($queryResult as $queryItem) {
    // doStuff($queryItem);
}