php - how to return array for mysql_query? -


  // make empty array   $sqlarray=array();   $jsonarray=array();     // start need fast working alternatİves -----------------------------------------------------   // first 20 vistors   $query = "select user_id vistors limit 20";    $result = mysql_query ($query) or die ($query);    // make vistors user query array   while ($vstr_line = mysql_fetch_array($result)){     array_push($sqlarray, $vstr_line['user_id']);   }    // implode vistors user array   $sqlarray_impl = implode("', '", $sqlarray);  // end need fast working alternatİves -----------------------------------------------------     // vistors information   $query = "select id, username, picture users id in ('$sqlarray_impl')";    $qry_result = mysql_query($query) or die($query);     while ($usr_line = mysql_fetch_array($qry_result)){     array_push($jsonarray, $usr_line['id'].' - '.$usr_line['username'].' - '.$usr_line['picture']);   }     print_r($sqlarray);    echo '<br><br>';    print_r($jsonarray); 

see functions.. need replacement fast working alternatives..

function within range specified above, me, running faster alternative. query return array ?

thx helpers !

  1. can use join or sub select reduce query count 2 1? might not give of boost worth shot , cleaner implementation.

  2. where bottleneck? db , not php code.

  3. are tables/columns indexed? run explain on both queries.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -