示例#1
0
 /**
  * Gets single user database row by selected row
  *
  * @param  int  $id
  * @return object
  */
 public function getUserBy($field, $id)
 {
     $result = $this->dc->qb()->select('*')->from($this->dc->p($this->config->get('foolz/foolframe', 'foolauth', 'table_name')), 't')->where($field . ' = ' . $this->dc->getConnection()->quote($id))->execute()->fetch();
     if (!$result) {
         throw new UsersWrongIdException();
     }
     return User::forge($this->getContext(), $result);
 }
示例#2
0
 public function save(array $data = [])
 {
     foreach ($data as $key => $item) {
         $this->{$key} = $item;
     }
     $set = [];
     foreach ($this->editable_fields as $filter) {
         $set[$filter] = $this->{$filter};
     }
     if (!is_null($set['password']) && $set['password'] !== '') {
         $set['password'] = password_hash($set['password'], PASSWORD_BCRYPT, ['cost' => 10]);
     } else {
         unset($set['password']);
     }
     $query = $this->dc->qb()->update($this->dc->p($this->config->get('foolz/foolframe', 'foolauth', 'table_name')))->where('id = :id')->setParameter(':id', $this->id);
     foreach ($set as $key => $item) {
         $query->set($this->dc->getConnection()->quoteIdentifier($key), $this->dc->getConnection()->quote($item));
     }
     $query->execute();
 }