Verify address book contacts iOS from PHP server -


i need check of addressbook users using ios app (using emails). this, send contacts list php server , check emails, registered. then, return array of users , show them in ios tableview. problem when have 100-200 contacts, retrieval lightening fast, when have 1000-1500 contacts takes @ least 3-4 minutes. how can improve it?

php code:     $handle = fopen('php://input','r');     $jsoninput = fgets($handle);     // decoding json array     $array = json_decode($jsoninput,true);      if (empty($array)) {         echo '<h1>array empty!!!<h1>';         return;     }      require('dbconnection.php');      $dbconnection = new dbconnection;      $link = $dbconnection->connecttodatabase();       if ($link)      {         $dbconnection->selectdatabase();          foreach($array $subarray)         {             foreach($subarray['email'] $email)             {                  $query="select email,picture user email='$email'";                  $result=  mysql_query($query);                   $row = mysql_fetch_assoc($result);                   if(mysql_num_rows($result) > 0)//if finds row                  {                      $contact = array(                         "fullname" => $subarray['fullname'],                          "email"   => $email,                         "picture" => "http://www.mysite.co/project/users/images/".$email."."."jpg"."?".time()                          );                          $returningarray[] =  $contact;                  }             }         }          echo json_encode($returningarray);     } 

if think of performance first thing need check how many db calls there because slow. need in case perform single mysql request emails got ios call:

select email, picture user email in ('email1', 'email2', ...) 

then need iterate through results of sql call, know of passed emails exist in database.

and should consider switching pdo sure.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -