Skip to content

Fatal error: Uncaught Error: Call to a member function prepare() on null in C:\xampp\htdocs\joblister\lib\Database.php:32 Stack trace: #0 C:\xampp\htdocs\joblister\lib\job.php(10): Database->query('SELECT jobs.*, ...') #1 C:\xampp\htdocs\joblister\index.php(15): Job->getAllJobs() #2 {main} thrown in C:\xampp\htdocs\joblister\lib\Database.php on line 32 #114

Open
@codesmith445

Description

@codesmith445
host .';dbname='. $this->dbname; // Set Options $options = array ( PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ); //PDO INSTANCE try { $this->dbh = new PDO($dsn, $this->user, $this->pass, $options); } catch(PDOException $e) { $this->error = $e->getMessage(); } } public function query($query) { $this->stmt = $this->dbh->prepare($query); } public function bind($param, $value, $type = null) { if(is_null($type)) { switch(true) { case is_int ( $value ) : $type = PDO::PARAM_INT; break; case is_bool ( $value ) : $type = PDO::PARAM_BOOL; break; case is_null ( $value ) : $type = PDO::PARAM_NULL; break; default : $type = PDO::PARAM_STR; } } $this->stmt->bindValue($param, $value, $type); } public function execute() { return $this->stmt->execute(); } public function resultSet() { $this->execute(); return $this->stmt->fetchAll(PDO::FETCH_OBJ); } public function single() { return $this->stmt->fetch(PDO::FETCH_OBJ); } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions