如何在mysql php中无需一段时间获取所有可用行

如何在mysql php中无需一段时间获取所有可用行

问题描述:

If I wanted to fetch multiple ROWS without doing the while loop like this:

while ($data = mysql_fetch_array($select)) {}

how can I do that in mysql and php?

如果我想在不执行while循环的情况下获取多个ROWS: p> while($ data = mysql_fetch_array($ select)){} code> pre>

我怎么能在mysql和php中做到这一点? p> \ n div>

mysql_fetch_array() is intended to fetch a single row from a resultset, so there is no reasonable way not using a while. Use mysqli with fetch_all or get used to while :)

Your comment:

$_SESSION["whatever"]=array();
while($data = mysql_fetch_array($select)) {
   array_push($_SESSION["whatever"], $data);
}

With mysqli you have a fetch_all function. From the manual:

mysqli_result::fetch_all -- mysqli_fetch_all — Fetches all result rows as an associative array, a numeric array, or both