Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Strict Standards: Non-static method DAO::getInstance() should not be called statically, assuming $this (...)
MenTo(S)
post
Post #1





Grupa: Zarejestrowani
Postów: 27
Pomógł: 3
Dołączył: 9.05.2013
Skąd: Kielce

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


Tak jak w temacie strona sypie errorsami aż miło.
Ktoś wie może gdzie jest błąd ?
Kod
Strict Standards: Non-static method DAO::getInstance() should not be called statically on line 40

    $DAO = DAO::getInstance(); - 40 linijka
    $DAO->connect(CONFIG::DB_ACCOUNTS);
    $DAO->connect(CONFIG::DB_PLAYERS);
    
    
    for($i = 0; $i != count($DAO->dbname); $i++){
        if(!$DAO->isConnected($DAO->dbname[$i])) die('Unable connect to database: '.$DAO->dbname[$i].'<br/><br/>'.($DAO->getConnectException($DAO->dbname[$i])));
    }
    
    $accounts = $DAO->getInstance()->getHandle(CONFIG::DB_ACCOUNTS);
    $players = $DAO->getInstance()->getHandle(CONFIG::DB_PLAYERS);

Strict Standards: Accessing static property DAO::$db as non static in on line 22

Strict Standards: Accessing static property DAO::$db as non static in on line 34

Strict Standards: Accessing static property DAO::$db as non static in on line 29

Strict Standards: Accessing static property DAO::$db as non static in on line 29

        function connect($dbname){            
            $this->dbname[] = $dbname;
            
            $dsn = 'mysql:dbname='.$dbname.';host='.CONFIG::MYSQL_HOST.';port='.CONFIG::MYSQL_PORT;
            try{
                $this->db[$dbname] = new PDO($dsn, CONFIG::MYSQL_USER, CONFIG::MYSQL_PASS); - 22 linijka
            } catch(PDOException $e) {
                $this->connect_exception[$dbname] = $e;                
            }
        }
    
        function getHandle($dbname){
            if(isset($this->db[$dbname])) return $this->db[$dbname]; - 29 linijka
            else throw new Exception('Try get handle to <b>'.$dbname.'</b>. Database <b>'.$dbname.'</b> doesn\'t exists.');
        }
    
        function isConnected($dbname){
            return (is_object($this->db[$dbname])); - 34 linijka
        }
        
        function getConnectException($dbname){
            if(isset($this->connect_exception)){
                return $this->connect_exception[$dbname];
            }
        }

Strict Standards: Non-static method DAO::getInstance() should not be called statically, assuming $this from incompatible context on line 7

Strict Standards: Non-static method DAO::getInstance() should not be called statically, assuming $this from incompatible context on line 7

Strict Standards: Non-static method DAO::getInstance() should not be called statically, assuming $this from incompatible context on line 10

Strict Standards: Non-static method DAO::getInstance() should not be called statically, assuming $this from incompatible context on line 10

        public function __construct() {            
            if(DAO::getInstance()->isConnected(account)) $this->accounts = DAO::getInstance()->getHandle(account); - 7 linijka
            else throw new Exception('Błąd połączenia do bazy danych: '.CONFIG::DB_ACCOUNTS); -7 linijka
            
            if(DAO::getInstance()->isConnected(player)) $this->players = DAO::getInstance()->getHandle(player); - 10 linijka
            else throw new Exception('Błąd połączenia do bazy danych: '.CONFIG::DB_PLAYERS);            -10 linijka
        }


Ten post edytował MenTo(S) 9.05.2013, 07:47:36
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: 22.08.2025 - 04:57