简体   繁体   中英

php mysql fetch array in global

i got this code

     while ($aResult = mysql_fetch_array($result))
  {
   $sResult[$aResult[userID]] = $aResult;
  }

but i want to know is there a faster way to put everything from $aresult in the sresult global?

It depends on the definition of "faster". If you want minimum CPU usage, you propably should use the function above, or as Col. said, try to avoid fetching all and use pointers.

If you want less coding time, consider using aa wrapper such as PEAR DB. With it you can just write $res = $db->getAll( $SQL );

http://pear.php.net/manual/en/package.database.db.db-common.getall.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM