Exemple #1
0
 public function save(User $user)
 {
     $query = "SELECT * FROM users WHERE username = ?";
     $this->db->query($query, [$user->getUsername()]);
     $result = $this->db->row();
     if ($result) {
         echo 'The username already taken!';
         die;
     }
     $query = "\n            INSERT INTO users (username, email, cash, roleId, password)\n            VALUES (?, ?, ?, ?, ?)\n        ";
     $params = [$user->getUsername(), $user->getEmail(), floatval($user->getCash()), $user->getRole(), $user->getPassword()];
     if ($user->getId()) {
         $query = "UPDATE players SET username = ?, password = ? WHERE id = ?";
         $params[] = $user->getId();
     }
     $this->db->query($query, $params);
     return $this->db->rows() > 0;
 }
Exemple #2
0
 /**
  * Declares an association between this object and a ChildUser object.
  *
  * @param  ChildUser $v
  * @return $this|\Models\Group The current object (for fluent API support)
  * @throws PropelException
  */
 public function setOwner(ChildUser $v = null)
 {
     if ($v === null) {
         $this->setOwnerId(NULL);
     } else {
         $this->setOwnerId($v->getId());
     }
     $this->aOwner = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildUser object, it will not be re-added.
     if ($v !== null) {
         $v->addMyGroup($this);
     }
     return $this;
 }
 public function getId()
 {
     $this->_load();
     return parent::getId();
 }
 /**
  * {@inheritDoc}
  */
 public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) parent::getId();
     }
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array());
     return parent::getId();
 }
Exemple #5
0
 /**
  * Exclude object from result
  *
  * @param   ChildUser $user Object to remove from the list of results
  *
  * @return $this|ChildUserQuery The current query, for fluid interface
  */
 public function prune($user = null)
 {
     if ($user) {
         $this->addUsingAlias(UserTableMap::COL_ID, $user->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Exemple #6
0
 /**
  * Filter the query by a related \Models\User object
  *
  * @param \Models\User|ObjectCollection $user The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildCategoryQuery The current query, for fluid interface
  */
 public function filterByUser($user, $comparison = null)
 {
     if ($user instanceof \Models\User) {
         return $this->addUsingAlias(CategoryTableMap::COL_USER_ID, $user->getId(), $comparison);
     } elseif ($user instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(CategoryTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByUser() only accepts arguments of type \\Models\\User or Collection');
     }
 }
 /**
  * Salva o cookie de autenticação
  * @param  \Models\User $user Objeto \Models\User do usuário logado
  */
 public static function saveSessionCookieForUser(\Models\User $user)
 {
     $cookieData = ['id' => $user->getId(), 'token' => $user->getToken()];
     // 2592000 = 60 * 60 * 24 * 30, ou seja, 30 dias em segundos
     setcookie(AUTH_USER_COOKIE_NAME, serialize($cookieData), time() + 2592000);
 }
Exemple #8
0
 /**
  * Filter the query by a related \Models\User object
  *
  * @param \Models\User $user The related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildSharedQuery The current query, for fluid interface
  */
 public function filterByUser($user, $comparison = null)
 {
     if ($user instanceof \Models\User) {
         return $this->addUsingAlias(SharedTableMap::COL_TO_TYPE, 'user', $comparison)->addUsingAlias(SharedTableMap::COL_TO_ID, $user->getId(), $comparison);
     } else {
         throw new PropelException('filterByUser() only accepts arguments of type \\Models\\User');
     }
 }
 private static function update(User $model)
 {
     $db = Database::getInstance('app');
     $query = "UPDATE users SET username= :username, email= :email, password= :password, role_id= :role_id, f_name= :f_name, l_name= :l_name, gender= :gender, date_of_birth= :date_of_birth, registered_at= :registered_at WHERE id = :id";
     $result = $db->prepare($query);
     $result->execute([':id' => $model->getId(), ':username' => $model->getUsername(), ':email' => $model->getEmail(), ':password' => $model->getPassword(), ':role_id' => $model->getRole_id(), ':f_name' => $model->getF_name(), ':l_name' => $model->getL_name(), ':gender' => $model->getGender(), ':date_of_birth' => $model->getDate_of_birth(), ':registered_at' => $model->getRegistered_at()]);
 }
 public function updateUser(User $user)
 {
     $result = $this->db->prepare("\n\t\t\tUPDATE user\n\t\t\tSET money = ?,\n\t\t\t\tbanned = ?\n\t\t\tWHERE id = ?\n\t\t");
     $result->execute([$user->getMoney(), $user->getBanned(), $user->getId()]);
 }
Exemple #11
0
 /**
  * ### Starts a session for the given user
  *
  * @param \Models\User $user
  */
 private static function startSession($user)
 {
     $_SESSION['logged_in'] = 1;
     $_SESSION['user'] = $user->getId();
 }
 private static function update(User $model)
 {
     $db = Database::getInstance('app');
     $query = "UPDATE user SET username= :username, password= :password, registerDate= :registerDate, emailVerified= :emailVerified, email= :email, createdAt= :createdAt, updatedAt= :updatedAt WHERE id = :id";
     $result = $db->prepare($query);
     $result->execute([':id' => $model->getId(), ':username' => $model->getUsername(), ':password' => $model->getPassword(), ':registerDate' => $model->getRegisterDate(), ':emailVerified' => $model->getEmailVerified(), ':email' => $model->getEmail(), ':createdAt' => $model->getCreatedAt(), ':updatedAt' => $model->getUpdatedAt()]);
 }
Exemple #13
0
 /**
  * Declares an association between this object and a ChildUser object.
  *
  * @param  ChildUser $v
  * @return $this|\Models\Notification The current object (for fluent API support)
  * @throws PropelException
  */
 public function setOriginUser(ChildUser $v = null)
 {
     if ($v === null) {
         $this->setOriginType(null);
     } else {
         $this->setOriginType('user');
     }
     if ($v === null) {
         $this->setOriginId(NULL);
     } else {
         $this->setOriginId($v->getId());
     }
     $this->aOriginUser = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildUser object, it will not be re-added.
     if ($v !== null) {
         $v->addNotificationRelatedByOriginTypeOriginId($this);
     }
     return $this;
 }