private static function getUserFromDatabase()
 {
     $userTable = new ColumnsParser();
     $db = Db::getInstance(DatabaseConfig::DB_INSTANCE);
     $statement = $db->query("show columns from users");
     $columns = array_map(function ($c) {
         return ['name' => $c['Field'], 'type' => $c['Type']];
     }, $statement->fetchAll());
     if (count($columns) == 0) {
         return null;
     }
     foreach ($columns as $column) {
         $userTable->setColumn($column['name'], $column['type']);
     }
     return $userTable;
 }
 private static function insert(Lecturesspeaker $model)
 {
     $db = Db::getInstance(\ConferenceScheduler\Configs\DatabaseConfig::DB_INSTANCE);
     $query = "INSERT INTO lecturesspeakers (lectureId,speakerId) VALUES (:lectureId, :speakerId);";
     $result = $db->prepare($query);
     $result->execute([':lectureId' => $model->getLectureId(), ':speakerId' => $model->getSpeakerId()]);
     $model->setId($db->lastInsertId());
 }
 private static function insert(Usersrole $model)
 {
     $db = Db::getInstance(\ConferenceScheduler\Configs\DatabaseConfig::DB_INSTANCE);
     $query = "INSERT INTO usersroles (userId,roleId) VALUES (:userId, :roleId);";
     $result = $db->prepare($query);
     $result->execute([':userId' => $model->getUserId(), ':roleId' => $model->getRoleId()]);
     $model->setId($db->lastInsertId());
 }
 private static function insert(Conference $model)
 {
     $db = Db::getInstance(\ConferenceScheduler\Configs\DatabaseConfig::DB_INSTANCE);
     $query = "INSERT INTO conferences (Name,VenueId,Start,End,OwnerId) VALUES (:Name, :VenueId, :Start, :End, :OwnerId);";
     $result = $db->prepare($query);
     $result->execute([':Name' => $model->getName(), ':VenueId' => $model->getVenueId(), ':Start' => $model->getStart(), ':End' => $model->getEnd(), ':OwnerId' => $model->getOwnerId()]);
     $model->setId($db->lastInsertId());
 }
 public function insertRole($role) : bool
 {
     $db = Db::getInstance(DatabaseConfig::DB_INSTANCE);
     $statement = $db->prepare(self::INSERT_ROLE);
     try {
         $statement->execute([$role]);
         return $statement->rowCount() > 0;
     } catch (\Exception $ex) {
         return false;
     }
 }
 private static function insert(Role $model)
 {
     $db = Db::getInstance(\ConferenceScheduler\Configs\DatabaseConfig::DB_INSTANCE);
     $query = "INSERT INTO roles (name) VALUES (:name);";
     $result = $db->prepare($query);
     $result->execute([':name' => $model->getName()]);
     $model->setId($db->lastInsertId());
 }
示例#7
0
 private function __construct()
 {
     $dbConfig = new DatabaseConfig();
     $this->db = Db::getInstance($dbConfig::DB_NAME);
 }
 private static function insert(Hall $model)
 {
     $db = Db::getInstance(\ConferenceScheduler\Configs\DatabaseConfig::DB_INSTANCE);
     $query = "INSERT INTO halls (Name,places,venueId) VALUES (:Name, :places, :venueId);";
     $result = $db->prepare($query);
     $result->execute([':Name' => $model->getName(), ':places' => $model->getPlaces(), ':venueId' => $model->getVenueId()]);
     $model->setId($db->lastInsertId());
 }
 private static function insert(User $model)
 {
     $db = Db::getInstance(\ConferenceScheduler\Configs\DatabaseConfig::DB_INSTANCE);
     $query = "INSERT INTO users (username,password,email,telephone) VALUES (:username, :password, :email, :telephone);";
     $result = $db->prepare($query);
     $result->execute([':username' => $model->getUsername(), ':password' => $model->getPassword(), ':email' => $model->getEmail(), ':telephone' => $model->getTelephone()]);
     $model->setId($db->lastInsertId());
 }