Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php/xml] Przszpieszenie kodu aktualizacji xml, Hurtownia azymut
einter-project
post
Post #1





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 9.09.2011

Ostrzeżenie: (10%)
X----


Witam

Napisałem integracje z azymut.pl, niestety sama aktualizacja cen trwa kilka godzin. Czy można jeszcze zoptymalizować kod aby aktualizacja trwała krócej?

Tabela z produktami ma 91 026 rekordów i waży 78,6 MB


Plik xml waży 4,9M i ma 76960 linii.

Struktura pliku:

<?xml version="1.0" encoding="ISO-8859-2"?>

<!DOCTYPE prices SYSTEM "http://services.azymut.pl/oferta/price.dtd">
<prices updated="2011-12-16 17:45:38">
<book indeks="00124700100KV" cena="15.41" vat="23" detal="24.61" />
<book indeks="00130100101KA" cena="10.06" vat="23" detal="16.49" />
<book indeks="00151500101KS" cena="8.25" vat="5" detal="11.55" />
<book indeks="00171000105KS" cena="30.8" vat="5" detal="42.0" />
<book indeks="00195900101KS" cena="9.75" vat="5" detal="13.65" />
<book indeks="00204500101KS" cena="15.0" vat="5" detal="21.0" />
<book indeks="00226800101KS" cena="9.75" vat="5" detal="13.65" />

.........


<book indeks="8DB70601415KS" cena="14.93" vat="5" detal="20.9" />
<book indeks="8DB70701415KS" cena="22.43" vat="5" detal="31.4" />
<book indeks="8DB70801415KS" cena="22.43" vat="5" detal="31.4" />
<book indeks="8DB70901415KS" cena="22.43" vat="5" detal="31.4" />
<book indeks="8DB73101415KS" cena="16.43" vat="5" detal="23.0" />
<book indeks="8DB73201415KS" cena="16.43" vat="5" detal="23.0" />
<book indeks="9PA00301415KS" cena="13.61" vat="5" detal="285.8" />
<book indeks="9PA00401415KS" cena="15.0" vat="5" detal="21.0" />
<book indeks="9PB00101415KS" cena="13.5" vat="5" detal="18.9" />
<book indeks="9PB00201415KS" cena="13.5" vat="5" detal="18.9" />
</prices>

Kod php do obsługi pliku:
  1. <?php
  2. $reader = new XMLReader();
  3. $reader->open('ceny4.xml');
  4.  
  5. $counter = 0;
  6. while($reader->read()) {
  7. if($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'book') {
  8. $indeks = $reader->getAttribute('indeks');
  9. $vat = $reader->getAttribute('vat');
  10. $detal = $reader->getAttribute('detal');
  11. $kplD = $reader->getAttribute('kplD');
  12.  
  13.  
  14.  
  15.  
  16. $mysql->exec("UPDATE `shop_product` SET `product_price_update`=now(), `product_price_netto`='".$detal."', `product_komplet`='".$kplD."', `product_vat`='".$vat."'
  17. WHERE `product_number_catalog_producer`='".$indeks."'");
  18.  
  19. print $indeks.' - '.$vat.' - '.$detal.' - '.$kplD.'<br>';
  20.  
  21. $counter++;
  22. }
  23. }
  24. $reader->close();
  25. ?>


Aktualizacja bazy oparta jest o klasę obsługującą PDO

Bardzo prosiłbym o uwagi.

// Edit
Puściłem aktualizacje o 2011-12-16 18:28:15 i do godziny 2011-12-16 19:23:01 zaktualizował 6 448.

Ten post edytował einter-project 16.12.2011, 19:49:28
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
einter-project
post
Post #2





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 9.09.2011

Ostrzeżenie: (10%)
X----


Nie rozumiem po co piszesz jak nie chcesz pomóc.
1) dostałem na pw, istnieje coś takiego na tym forum
2) wiem że nie ma takiej funkcji, dlatego piszę co jest nie tak

Chyba sobie poradziłem więc dzięki za wysiłek.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 27.08.2026 - 20:03