Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> błąd przy inkrementacji zmiennej
bela
post
Post #1


Administrator PHPedia.pl


Grupa: Developerzy
Postów: 1 102
Pomógł: 2
Dołączył: 14.09.2003

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


  1. <?php
  2. /*
  3.  * klasa mysql
  4.  */
  5.  
  6. class mysql {
  7. var $conn_id;
  8. var $result;
  9. var $number_queries = 0;
  10.  
  11. function mysql($host, $user, $pass, $db) {
  12. $this->conn_id = mysql_connect($host, $user, $pass) or die(&#092;"Brak po??czenia\");
  13. mysql_select_db($db) or die(&#092;"Nie mo?na wybra? bazy\");
  14. }
  15.  
  16. function query($query) {
  17. $this->number_queries++;
  18. return $this->result = mysql_query($query);
  19. }
  20.  
  21. function get_number_queries() {
  22. return $this->number_queries;
  23. }
  24.  
  25. }
  26.  
  27. ?>


dlaczego po wykonaniu zapytania, podczas pobrania liczby zapytan przez get_number_queries() jest wracane 0?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
bela
post
Post #2


Administrator PHPedia.pl


Grupa: Developerzy
Postów: 1 102
Pomógł: 2
Dołączył: 14.09.2003

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


o tak:
  1. <?php
  2. /**
  3. * J?dro sytemu
  4. * @package belacms
  5. * @author bela_666
  6. */
  7.  
  8.  
  9. require_once(&#092;"inc/config.php\");
  10. require_once(&#092;"inc/mysql.php\");
  11.  
  12.  
  13. class kernel {
  14.  
  15.         /**
  16.     * Referencja modu?u
  17.     */
  18.         var $module;
  19.         var $mod;
  20.     
  21.     var $config;
  22.     var $db;
  23.  
  24.     /**
  25.     * Konstruktor
  26.     * ?aduje modu?
  27.     */
  28.         function kernel() {
  29.  
  30.             $this->config = new config();
  31.         $this->db = new mysql($this->config->dbhost, $this->config->dbuser, $this->config->dbpass, $this->config->dbname);
  32.     }
  33. }
  34. ?>


a potem
  1. <?php
  2.  
  3. $smarty->assign(&#092;"number_queries\", $kernel->db->number_queries);
  4.  
  5. ?>

pokazuje 0

Ten post edytował bela_666 21.09.2004, 12:36:08
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 11.10.2025 - 02:35