How to enter this information in the mysql database?

Asked

Viewed 390 times

-1

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

Erasing and writing all over again:

  • The $pegacodigos through a loop picks up all the CODIGO on the table IMOVEL
  • Guard as array to scroll through this script http://pastebin.com/MPd3cS9C
  • Start selecting on web-service all photos to $codigo['CODIGO']
  • And starts to insert into the second script database fields as per attached image

This http://pastebin.com/MPd3cS9C does exactly what I want but takes too long to know that he will never be able to perform the task I need.

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

Help me discover the error of logic?

inserir a descrição da imagem aqui

  • 1

    What purpose of Soap for this array?

  • The purpose of it is to make the connection and give access to all the data related to each property that is in this remote server.

1 answer

2

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

  • take out the while
  • enter a code manually (line 13)
  • var_dump(or print_r) the $res and copy the result
  • repeat the process with another code

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

Addendum to the author’s comment

I would try with another code to compare, because when it comes to images, 55 thousand records per code seems a lot.follows below an alternative of Insert

replace lines 27 to 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));
  • 1

    I did the test with only one code manually and it returns me all the images referring to that code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.