mysqli query only returning first row

前端 未结 5 2070
不思量自难忘°
不思量自难忘° 2020-12-12 03:16

I am migrating from mysql to mysqli, and I am having trouble returning more than one row from the database in a query.

$db = new mysqli($hostname, $sql_us, $         


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 03:24

    $arr = array();
    if ($type == 'assoc') {
      while($row = $result->fetch_assoc()) {
        $arr[] = $row;
      }
    }
    else {    
      while($row = $result->fetch_object()) {
        $arr[] = $row;   
      }
    }
    return $arr;
    

提交回复
热议问题