How to insert this information in the mysql database?

-1
$pegacodigos    = mysql_query("SELECT CODIGO FROM imovel"); 
while($codigo = mysql_fetch_array($pegacodigos){ ...

Deleting and rewriting everything:

  • The $pegacodigos through a loop takes all CODIGO in the IMOVEL
  • Save as array to go through this script link
  • Starts to select in web-service all photos for $codigo['CODIGO']
  • And begins to insert into the second bank script fields as attached image

This link does exactly what I want but it takes too long to know that it will never accomplish the task I need.

For me, I have with me that loop is in the wrong place making it for every photo he retrieves, he makes 1 connection in the web-service or making more loops than necessary. The $res that is the result of $array with $client returns the 55 thousand photos, while is embracing everything, so there is some problem there causing extreme slowness.

Help me figure out the logic bug?

    
asked by anonymous 08.09.2014 / 21:57

1 answer

2

I have the impression that with every entry in the webservice, you are picking up all the images. I would do a test type:

  • throw while
  • Enter a code manually (line 13)
  • Make a var_dump (or print_r) of $ res and copy the result
  • repeat the process with another code

Then you compare the results of the two webservice queries, see if they are listing the same things

Adding to the author's comment

I would try with another code to compare, because if it is about images, 55,000 records per code seems a lot to me.

  

Replace from lines 27 through 36

$sql = array(); 
foreach( $data as $row ) {
    $c = $res[$j]['Codigo'];
    $d = $res[$j]['Foto'];
    $e = $res[$j]['Thumbnail'];
    $sql[] = "('{$codigo['CODIGO']}', '{$c}', '{$d}', '{$e}')";
}
mysql_query('INSERT INTO imagens (IMOVEL, CODIGO, IMAGEM_G, IMAGEM_P) VALUES '.implode(',', $sql));
    
11.09.2014 / 07:30