Mam oto taki skrypt:
<?php
class bazadanych
{
public $log;
public $log_string;
public $log_rodzaj;
public $log_error;
public function __construct($rodzaj, $host, $user, $password, $db)
{
$this -> wybor_bazy_danych($rodzaj, $host, $user, $password, $db);
$this -> rodzaj = $rodzaj ;
$this -> log($this -> log, $this -> log_string, $this -> log_rodzaj, $this -> log_error) ;
}
public function wybor_bazy_danych($rodzaj, $host, $user, $password, $db)
{
if ($rodzaj == 'mysql')
{
if (!$connect)
{
$this -> log = 'error';
$this -> log_string = 'polaczenie z baza danych';
$this -> log_rodzaj = 'funkcja $bazadanych ->wybor_bazy_danych()';
die ( include ('system/jadro/e-door/includes/error_bazadanych.php')); }
}
elseif ($rodzaj == 'pg')
{
if (!$connect)
{
$this -> log = 'error';
$this -> log_string = 'polaczenie z baza danych';
$this -> log_rodzaj = 'funkcja $bazadanych ->wybor_bazy_danych()';
$this -> log_error = pg_error();
die ( include ('system/jadro/e-door/includes/error_bazadanych.php')); }
}
if($connect and $rodzaj =='mysql' ) {
if (!$connect_db)
{
$this -> log = 'error';
$this -> log_string = 'wybor bazy danych';
$this -> log_rodzaj = 'funkcja $bazadanych ->wybor_bazy_danych()';
die ( include ('system/jadro/e-door/includes/error_bazadanych_db.php'));
}
}
elseif($connect and $rodzaj =='pg' )
{
$connect_db = @pg_select_db($db) ;
if (!$connect_db)
{
$this -> log = 'error';
$this -> log_string = 'wybor bazy danych';
$this -> log_rodzaj = 'funkcja $bazadanych ->wybor_bazy_danych()';
die ( include ('system/jadro/e-door/includes/error_bazadanych_db.php'));
}
}
if($connect_db) { return true; } else {return false; }
}
//wykonywanie polecen SQL
public static function wykonaj
($polecenie) {
#mysql
if ('mysql' == $this -> rodzaj)
{
if ($zapytanie)
{
return $zapytanie;
}
else
{
$this -> log ='error';
$this -> log_string = $polecenie ;
$this -> log_rodzaj = 'funkcja $bazadanych -> wykonaj()';
}
}
#postgresql
if ('pg' == $this -> rodzaj)
{
if ($zapytanie)
{
return $zapytanie;
}
else
{
$this -> log = 'error';
$this -> log_string = $polecenie ;
$this -> log_rodzaj = 'funkcja $bazadanych -> wykonaj()';
$this -> log_error = pg_error() ;
}
}
}
//System logów
public function log($log, $string, $rodzaj, $error)
{
if ('error' == $log)
{
$data = date('Y-m-d H:i:s'); return 'Data: '.$data.', Rodzaj bazy danych: '.$this -> rodzaj.' Rodzaj błędu: '.$rodzaj.', Wykonywane działanie: '.$string.', Wartość błędu: '.$error ;
}
}
}
?>
Teraz po ustawieniu metody statycznej, wywala mi błąd, że w lini 96 ($this -> rodzaj) nie jest obiektem. Jak to poprawic?