<?php

class GatewayAdministrator
{
    private $con;

    public function __construct($con)
    {
        $this->con = $con;
    }

    public function addAdministrator($Administrator)
    {
        $query = "insert into Administratoristrator(id,username,password) values (:id,:username,:password);";
        $this->con->executeQuery(
            $query,
            array(
                ':id' => array($Administrator->getId(), PDO::PARAM_INT),
                ':username' => array($Administrator->getUsername(), PDO::PARAM_STR),
                ':password' => array(password_hash($Administrator->getPassword(), PASSWORD_DEFAULT), PDO::PARAM_STR)
            )
        );
    }


    public function getCredential($login)
    {
        $query = "SELECT password FROM Administrator WHERE username = :login;";
        $this->con->executeQuery($query, array(':login' => array($login, PDO::PARAM_STR)));
        $results = $this->con->getResults();
        if ($results == NULL) {
            return false;
        }
        return $results[0]['password'];
    }
}
