1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
Accommodation_Management/models/Accomodation.php

34 lines
No EOL
836 B
PHP

<?php
class Accomodation extends Model
{
private $data;
public function __construct($data = null)
{
parent::__construct();
$_col = get_class()::getColumns();
if($data !== null){
forEach($data as $key=>$value){
if(!key_exists($key, $_col)){
throw new Exception('Invalid data entry');
}else{
$this->data[$key] = $value;
}
}
}
return $this;
}
public static function fetchByUser(User $user)
{
if($user->getAccomodationId()) {
$data = Accomodation::fetch(array(['id','=', $user->getAccomodationId()]));
if(count($data) === 1){
return $data[0];
}
}
return false;
}
}