Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

2 Stron V   1 2 >  
Reply to this topicStart new topic
> Xdebug nie debuguje
Matrix12
post
Post #1





Grupa: Zarejestrowani
Postów: 144
Pomógł: 0
Dołączył: 22.03.2015

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


Witam,


zainstalowałem xdebuga, do prostych plików działa natomiast jak mam klasę i każe mu coś zdebugować to niestety nic się nie dzieje... wyświetla tylko $this->db jako pusty a powinno być pełne.. Macie jakieś pomysły jak to naprawić albo debugować?
Go to the top of the page
+Quote Post
MESSIAH :)
post
Post #2





Grupa: Zarejestrowani
Postów: 249
Pomógł: 0
Dołączył: 22.12.2011

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


Jakieś podpowiedzi?
Go to the top of the page
+Quote Post
Matrix12
post
Post #3





Grupa: Zarejestrowani
Postów: 144
Pomógł: 0
Dołączył: 22.03.2015

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


Dziwny przypadek ogólnie, nie wiem dlaczego zwykła zmienna debaguje a metod nie
Go to the top of the page
+Quote Post
Pyton_000
post
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Moja magiczna kula niestety nie widzi Twojego kodu (IMG:style_emoticons/default/sad.gif) Chyba się popsuła...
Go to the top of the page
+Quote Post
Matrix12
post
Post #5





Grupa: Zarejestrowani
Postów: 144
Pomógł: 0
Dołączył: 22.03.2015

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


Index.php
  1. <?php
  2.  
  3.  
  4. $app = new Application(new Database);
  5. $app->allProducts();



  1. <?php
  2.  
  3.  
  4. class Application
  5. {
  6. private $db;
  7.  
  8. public function __construct(Database $database)
  9. {
  10. $this->db = $database;
  11. }
  12.  
  13.  
  14. public function allProducsts()
  15. {
  16. $products = $this->db->querySelect('SELECT * FROM products');
  17.  
  18. return $products;
  19. }
  20. }
  21.  
  22.  
  23.  
  24.  
  25.  
  26. class Database
  27. {
  28. protected $db;
  29.  
  30. public function __construct
  31. {
  32. $this->connectWithDatabase();
  33. }
  34. public function querySelect($param)
  35. {
  36. $stmt = $this->db->prepare($param);
  37. $stmt->execute();
  38. $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
  39. return $result;
  40. }
  41. protected function connectWithDatabase()
  42. {
  43. try {
  44. $this->db = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
  45.  
  46. } catch (PDOException $e) {
  47. print "Error!: " . $e->getMessage() . "<br/>";
  48. die();
  49. }
  50. }
  51. }




Kod dla testów tylko i wyłacznie
Go to the top of the page
+Quote Post
Pyton_000
post
Post #6





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


No dobra, a użycie? Co Ci nie wyświetla. Jak debugujesz.
Go to the top of the page
+Quote Post
Matrix12
post
Post #7





Grupa: Zarejestrowani
Postów: 144
Pomógł: 0
Dołączył: 22.03.2015

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


W xdebagu mam tylko $db = null i co zwraca $_SESSION i tyle. Zaremowałem cały kod w querySelect i dałem $result = 'Dupa' i tego mi nie zwraca już..

Ten post edytował Matrix12 24.08.2015, 08:29:58
Go to the top of the page
+Quote Post
nospor
post
Post #8





Grupa: Moderatorzy
Postów: 36 561
Pomógł: 6315
Dołączył: 27.12.2004




NIgdzie w kodzie nie ma $db wiec trudno oczekiwac by $db dawalo cos innego niz null
Go to the top of the page
+Quote Post
Pyton_000
post
Post #9





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


screena daj
Go to the top of the page
+Quote Post
Matrix12
post
Post #10





Grupa: Zarejestrowani
Postów: 144
Pomógł: 0
Dołączył: 22.03.2015

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


http://zapodaj.net/05a76939589eb.png.html

Jeszcze jedna czerowna kropka jest w application przy innej metodzie ale ta to już wgl nie działa.
Go to the top of the page
+Quote Post
Pyton_000
post
Post #11





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Przecież działa... db ma przypisany obiekt PDO....
Go to the top of the page
+Quote Post
Matrix12
post
Post #12





Grupa: Zarejestrowani
Postów: 144
Pomógł: 0
Dołączył: 22.03.2015

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


1. Dlaczego ma nulla skoro w application wywołuje allProduct
  1. public function allProducts()
  2. {
  3.  
  4. $domains = $this->database->doAction('querySelect', $params);
  5.  
  6. return $domains;
  7. }



tutaj nic się nei dzieje.

  1.  
  2. public function querySelect($params)
  3. {
  4. $stmt = $this->db->prepare($params);
  5. $stmt->execute();
  6.  
  7. $result = $stmt->fetchAll();
  8.  
  9. return $result;
  10. }



2. Czy ja muszę dodatkowo odpalić przeglądarkę by to mi debaugowało ?
Go to the top of the page
+Quote Post
Pyton_000
post
Post #13





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


CO? Zdecyduj się co Ci nie działa. Najpierw pytasz o jakieś $db teraz o coś innego.
Go to the top of the page
+Quote Post
Matrix12
post
Post #14





Grupa: Zarejestrowani
Postów: 144
Pomógł: 0
Dołączył: 22.03.2015

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


Jak widzisz ze screena $db daje nulla a w rzeczywiści zwraca dane z bazy
Go to the top of the page
+Quote Post
Pyton_000
post
Post #15





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Pokaż Ty mi na tym screenie $db == null
Go to the top of the page
+Quote Post
nospor
post
Post #16





Grupa: Moderatorzy
Postów: 36 561
Pomógł: 6315
Dołączył: 27.12.2004




Dołączam sie do prosby Pyton bo i mnie niezmiernie interesuje gdzie Ty na tym screenie widzisz nulla
Go to the top of the page
+Quote Post
Matrix12
post
Post #17





Grupa: Zarejestrowani
Postów: 144
Pomógł: 0
Dołączył: 22.03.2015

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


W nawiasie 0
Go to the top of the page
+Quote Post
Pyton_000
post
Post #18





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


You made My Day (IMG:style_emoticons/default/exclamation.gif) (IMG:style_emoticons/default/exclamation.gif)
(IMG:http://cdn.meme.am/instances/400x/50016982.jpg)

Ten post edytował Pyton_000 24.08.2015, 19:16:25
Go to the top of the page
+Quote Post
Matrix12
post
Post #19





Grupa: Zarejestrowani
Postów: 144
Pomógł: 0
Dołączył: 22.03.2015

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


Może nie wiem jak go używać.. powiedzcie mi jak mam testować poprzez xdebug?

Pomożecie mi w dobrym korzystaniu z tego narzędzia ?
Go to the top of the page
+Quote Post
Pyton_000
post
Post #20





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Najpierw to musisz wiedzieć CO chcesz debugować.
Go to the top of the page
+Quote Post

2 Stron V   1 2 >
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: 21.12.2025 - 07:04