![]() |
![]() |
![]()
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 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 1 527 Pomógł: 438 Dołączył: 28.06.2011 Skąd: Warszawa Ostrzeżenie: (0%) ![]() ![]() |
|
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 27 Pomógł: 3 Dołączył: 9.05.2013 Skąd: Kielce Ostrzeżenie: (0%) ![]() ![]() |
Prawdopodobnie w tej klasie DAO. Metody i własności nie są oznaczone jako STATIC po prostu. Zerknij na kod klasy i pododawaj operator static przy metodzie getInstance() - bo chyba o nią się rozchodzi.
Jedna kwestia załatwiona zostało jeszcze private static $db, $instance, $connect_exception; Kod 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]; } } Ten post edytował MenTo(S) 9.05.2013, 08:02:46 |
|
|
![]()
Post
#4
|
|
Grupa: Zarejestrowani Postów: 1 527 Pomógł: 438 Dołączył: 28.06.2011 Skąd: Warszawa Ostrzeżenie: (0%) ![]() ![]() |
Wszędzie tam gdzie masz odwołania do tych własności $db, $instance, $connect_exception sprawdź czy nie ma w DAO odwołań poprzez "$this->". Jeśli takowe są zamień $this->wlasnosc na self::$wlasnosc i będzie GIT. Dodatkowo polecam Ci zapoznanie się głębiej z obiektówką w PHP, z mteodami i własnościami statycznymi, tym kiedy stosować $this i self oraz na czym polega singleton.
|
|
|
![]()
Post
#5
|
|
Grupa: Zarejestrowani Postów: 27 Pomógł: 3 Dołączył: 9.05.2013 Skąd: Kielce Ostrzeżenie: (0%) ![]() ![]() |
Wszędzie tam gdzie masz odwołania do tych własności $db, $instance, $connect_exception sprawdź czy nie ma w DAO odwołań poprzez "$this->". Jeśli takowe są zamień $this->wlasnosc na self::$wlasnosc i będzie GIT. Dodatkowo polecam Ci zapoznanie się głębiej z obiektówką w PHP, z mteodami i własnościami statycznymi, tym kiedy stosować $this i self oraz na czym polega singleton. Serio nie wiem o co chodzi czy mógłbyś zerknąć na DAO? Całą noc szukałem rozwiązania i już nie mam siły...
Ten post edytował MenTo(S) 9.05.2013, 08:29:11 |
|
|
![]()
Post
#6
|
|
Grupa: Zarejestrowani Postów: 1 527 Pomógł: 438 Dołączył: 28.06.2011 Skąd: Warszawa Ostrzeżenie: (0%) ![]() ![]() |
Linijka 22 - zobacz sam. Do własności $db jest odwołanie poprzez "$this->db". Własność $db jest statyczna wg deklaracji z linijki 4 wobec czego powinno się do niej odwoływać poprzez self::$db a nie $this->db.
Trzeba to zamienić. Wszędzie tam gdzie masz:
daj zamiast tego:
i tyle (IMG:style_emoticons/default/wink.gif) |
|
|
![]() ![]() |
![]() |
Aktualny czas: 24.08.2025 - 04:45 |