41 ¹ø ±ÛÀÇ ´äÀå±Û: Re: [PHP] mysql_fetch_assoc() ¼Óµµ Æ©´× |
±Û¾´ÀÌ: »êÀÌ
[ȨÆäÀÌÁö]
|
±Û¾´³¯: 2003³â 07¿ù 03ÀÏ 00:25:30 ¸ñ(»õº®) |
Á¶È¸: 3952 |
$result = mysql_query($sql);
1. get all array
## good
##
while($tmp[] = mysql_fetch_assoc($result));
## some good
##
while($list = mysql_fetch_assoc($result))
{
$tmp[] = $list;
}
## not good
##
while($list = mysql_fetch_assoc($result))
{
$tmp[] = &$list;
}
## not good
##
$size = mysql_num_rows($result);
for($i=0; $i<$size; $i++)
{
$tmp[] = mysql_fetch_assoc($result);
}
## not good
##
$size = mysql_num_rows($result);
for($i=0; $i<$size; $i++)
{
$tmp[] = &mysql_fetch_assoc($result);
}
2. get partial array
## good
##
while($list = mysql_fetch_assoc($result))
{
...
... = &$list['foo'];
}
## not good
##
$size = mysql_num_rows($result);
for($i=0; $i<$size; $i++)
{
$list = mysql_fetch_assoc($result);
...
... = $list['foo'];
}
## not good
##
$size = mysql_num_rows($result);
for($i=0; $i<$size; $i++)
{
$list = mysql_fetch_assoc($result);
...
... = &$list['foo'];
}
|
ÀÌÀü±Û : Re: [PHP] use array() references
´ÙÀ½±Û : [SHELL] ¹®ÀÚ¿ º¯¼ö ÆĽÌ
|
from 61.254.75.40
JS(Redhands)Board 0.4 +@
|