function __construct($input = null)
 {
     parent::__construct($input);
     if ($this->role === null) {
         $this->role = 'user';
     }
 }
示例#2
0
 public function __construct($input = null)
 {
     parent::__construct($input);
     if ($this->role === null) {
         $this->role = 'admin';
     }
 }
示例#3
0
 /**
  * Constructor of this class. Used for creating a new DB connection and to set PDO modes.
  * @param \PDO          The PDO object
  */
 public function __construct()
 {
     $args = func_get_args();
     //get all arguments to this function
     if (isset($args[0]) && get_class($args[0]) === "PDO") {
         //If only one argument is present and if that argument is a PDO object and is directly passed in the argument, then do not create a new PDO object. Just use the old object
         $this->dbh = $args[0];
     } else {
         $dbConfig = new DatabaseConfig('pdo_sqlite', NULL, NULL, NULL);
         //get a new DB connection
         parent::__construct($dbConfig);
         //call the DatabaseModel's constructor to pass the DatabaseConfig object to initialize a new object
         $this->dbh = new \PDO("sqlite::memory:");
         //create a new PDO object
     }
     $this->dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
     //set PDO attributes
 }
示例#4
0
 /**
  * Constructor of this class. Used for creating a new DB connection and to set PDO modes.
  * @param db_name   The name of the DB
  * @param db_user   The username of the DB for connection
  * @param db_pass   The password of the DB for connection
  */
 public function __construct()
 {
     $args = func_get_args();
     //get all arguments to this function
     if (!isset($args[0])) {
         //If no arguments are set, then return false
         return false;
     }
     if (count($args) > 1) {
         $dbConfig = new DatabaseConfig('pdo_mysql', $args[0], $args[1], $args[2]);
         //get a new DB configuration
         parent::__construct($dbConfig);
         //call the DatabaseModel's constructor to pass the DatabaseConfig object to initialize a new object
         $this->dbh = new \PDO("mysql:dbname={$dbConfig->dbname};host={$dbConfig->host};", $dbConfig->username, $dbConfig->password);
         //create a new PDO object
     } elseif (get_class($args[0]) === "PDO") {
         //If only one argument is present and if that argument is a PDO object and is directly passed in the argument, then do not create a new PDO object. Just use the old object
         $this->dbh = $args[0];
     }
     $this->dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
     //set PDO attributes
 }
示例#5
0
 public function __construct()
 {
     parent::__construct();
 }