Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [OOP] Dodawanie poprzedniej wartości zmiennej - jak wyzerować
GreeN_DG
post
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 1
Dołączył: 3.12.2009

Ostrzeżenie: (0%)
-----


Witam. Mam pewien problem :

Powiedzmy że mam taką metodę klasy "imgfile" :

  1. public function isExistFile($imgid)
  2. {
  3. $this->filelink .= $imgid.'.jpg';
  4. if(file_exists($this->filelink))
  5. {
  6. return $this->filelink;
  7. }
  8. else
  9. {
  10. return $this->filelink;
  11. }
  12. }


Teraz w innej klasie wywołuję tą metodę :

  1. $upload = new imgfile;
  2.  
  3. while ($row = $wynik->fetch_assoc())
  4. {
  5.  
  6. if($akcja = $upload->isExistFile($row['imgid']))
  7. {
  8. print_r($akcja);
  9. array_push($this->imgtab, $row);
  10. }
  11. else
  12. {
  13. ...
  14. ...
  15. }
  16. }


$row['imgid'] - zawiera kolejne id obrazków np. 1,2,3,4

Po odpaleniu :

Daje mi takie coś :

  1. ../uimages/28.jpg../uimages/28.jpg29.jpg../uimages/28.jpg29.jpg30.jpg../uimages/28.jpg29.jpg30.jpg31.jpg


Zamiast zwrócić :

  1. ../uimages/28.jpg../uimages/29.jpg../uimages/30.jpg


Gdy w pętle 'while' dodam za każdym razem - $upload = new imgfile to problem się rozwiązuje (ale po co na nowo tworzyć obiekt klasy). Dlaczego metoda zwraca sumę kolejnych $row['imgid'] ?

Ten post edytował GreeN_DG 9.02.2011, 16:46:34
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: 22.12.2025 - 21:18