izniburak/pdox

Extends HK.

emreakdas opened this issue · 1 comments

class DB extends \Buki\Pdox
{
public $db;
public function __construct()
{
$configs = [
'host' => 'localhost',
'driver' => 'mysql',
'database' => 'table',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => ''
];
$this->db = parent::__construct($configs);
var_dump($this->db->table('uyeler')->getAll());
}

}

şöyle kullandığımda Call to undefined method PDO::table() hatası alıyorum. Direkt pdo görüyor böyle kullanamaz mıyım?

Merhabalar,
Böyle bir hata almanız normal, çünkü $this->db değişkenine parent::__construct metodunu atamışsınız ve bu metot void yani geriye herhangi bir şey döndürmez. Siz zaten PDOxu extend ediyorsunuz, parent construct'ı çağırdıktan sonra $this->table() şeklinde kullanmanız yeterli olur.

class DB extends \Buki\Pdox
{
    public $db;

    public function __construct()
    {
        $configs = [
            'host' => 'localhost',
            'driver' => 'mysql',
            'database' => 'table',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
            'collation' => 'utf8_general_ci',
            'prefix' => ''
        ];

        parent::__construct($configs);
        var_dump($this->table('uyeler')->getAll());
    }
}