public function __construct($request) { parent::__construct($request); $this->{$dbh} = new PDO("mysql:host=" . self::DB_CONFIG_HOST . ";dbname=" . self::DB_CONFIG_NAME . ";charset=" . self::DB_CONFIG_ENCD, self::DB_CONFIG_USER, self::DB_CONFIG_PASS); $this->{$dbh}->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if (!$this - $dbh) { throw new Exception('Error while establishing database connection!'); } }
public function __construct($request, $origin) { parent::__construct($request); // Abstracted out for example //$APIKey = new authaccess();//new Models\APIKey(); // if (!array_key_exists('apiKey', $this->input)) { // throw new Exception('No API Key provided'); // } else if (!$APIKey->verifyKey($this->input->apiKey, $origin)) { // throw new Exception('Invalid API Key'); // } else if (array_key_exists('token', $this->input) && // !$User->get('token', $this->input->token)) { // throw new Exception('Invalid User Token'); // } // $this->User = $User; }
public function __construct($db) { parent::__construct(); $this->db = $db; }