<?php
$app = [];
$app['config'] = require 'config.php';
require 'core/helpers.php';
require 'core/util.php';
require 'core/Router.php';
require 'core/Request.php';
require 'core/database/Connection.php';
require 'core/database/QueryBuilder.php';
require 'core/database/Account.php';
require 'models/Campaign.php';
This is how I code the Connection.php
<?php
class Connection
{
public static function make($config)
{
try {
return new PDO(
$config['connection'].';dbname='.$config['name'],
$config['username'],
$config['password'],
$config['options']
);
} catch (PDOException $e) {
die($e->getMessage());
// exit();
}
}
}
and in my
QueryBuilder.php
orAccount.php
file, i refer to it like
class QueryBuilder {
protected $pdo;
public function __construct($pdo){
$this->pdo = $pdo;
}
this specific query really is the problem here that's why I'm stucked ...
public static function check_if_the_email_is_currently_registered($pin){
$sql = "SELECT COUNT(*) FROM users WHERE email = :pin";
$statement = $this->pdo->prepare($sql);
$statement->execute();
$count = $statement->fetch(PDO::FETCH_NUM) ;
return reset($count);
}
I get this error
Fatal error: Uncaught Error: Using $this when not in object context