我有一个从我的数据库中返回行的函数,它工作正常,但我被告知写得不好,并且里面有很多不必要的代码。
我想知道是否有更简单,更简单的方法来重写此功能?
function gd($query) {
global $connect;
$fetch = mysqli_query($connect, $query);
$count = mysqli_num_rows($fetch);
while ($row=mysqli_fetch_array($fetch,MYSQLI_NUM)) {
$count --;
$arrayCount = count($myArray);
$tempArrayCount = 0;
while($tempArrayCount < $arrayCount){
$array[$count][$tempArrayCount]= $row[$tempArrayCount];
$tempArrayCount++;
} //end of while($tempArrayCount < $arrayCount)
} //end of while ($row=mysqli_fetch_array($fetch,MYSQLI_NUM))
return $array;
} //end of function gd($query)