Example #1
0
 public function saveExistingUser(User $user)
 {
     // These values should be sanitized
     // I believe this is fixed
     $query = "UPDATE users SET email=:email, age=:age, bio=:bio, is_admin=:admin, full_name=:fullname, address=:address, postcode=:postcode, bank_acc_num=:bank_acc_num, is_doctor=:is_doctor WHERE id=:userid";
     $stmt = $this->pdo->prepare($query);
     $email = $user->getEmail();
     $age = $user->getAge();
     $bio = $user->getBio();
     $admin = $user->isAdmin();
     $fullname = $user->getFullname();
     $address = $user->getAddress();
     $postcode = $user->getPostcode();
     $bank_acc_num = $user->getBankAccNum();
     $is_doctor = $user->isDoctor();
     $userid = $user->getUserId();
     $stmt->bindParam(':email', $email);
     $stmt->bindParam(':age', $age);
     $stmt->bindParam(':bio', $bio);
     $stmt->bindParam(':admin', $admin);
     $stmt->bindParam(':fullname', $fullname);
     $stmt->bindParam(':address', $address);
     $stmt->bindParam(':postcode', $postcode);
     $stmt->bindparam(':bank_acc_num', $bank_acc_num);
     $stmt->bindParam(':is_doctor', $is_doctor);
     $stmt->bindParam(':userid', $userid);
     return $stmt->execute();
 }
 public function saveExistingUser(User $user)
 {
     // Prepare statement
     $stmt = $this->pdo->prepare("UPDATE users " . "SET email=:email, age=:age, bio=:bio, isadmin=:isadmin, fullname=:fullname, address=:address, postcode=:postcode WHERE id=:userid");
     // Execute and bind values all in one
     return $stmt->execute(['userid' => $user->getUserId(), 'email' => $user->getEmail(), 'age' => $user->getAge(), 'bio' => $user->getBio(), 'isadmin' => $user->isAdmin(), 'fullname' => $user->getFullname(), 'address' => $user->getAddress(), 'postcode' => $user->getPostcode()]);
 }
Example #3
0
 public function saveExistingUser(User $user)
 {
     $stmt = $this->pdo->prepare(self::UPDATE_QUERY);
     $stmt->execute(array($user->getEmail(), $user->getAge(), $user->getBio(), $user->isAdmin(), $user->isDoctor(), $user->getFullname(), $user->getAddress(), $user->getPostcode(), $user->getBankcard(), $user->getMoneyspent(), $user->getMoneyearned(), $user->getUserId()));
     return $stmt->rowCount();
 }
Example #4
0
 public function saveExistingUser(User $user)
 {
     $query = self::UPDATE_QUERY;
     $query_params = array(':email' => $user->getEmail(), ':age' => $user->getAge(), ':bio' => $user->getBio(), ':role' => $user->isAdmin(), ':fullname' => $user->getFullname(), ':address' => $user->getAddress(), ':postcode' => $user->getPostcode(), ':id' => $user->getUserId(), ':bankcard' => $user->getBankCard());
     try {
         $stmt = $this->pdo->prepare($query);
         $stmt->execute($query_params);
         return 1;
     } catch (PDOException $ex) {
         die("Failed to run query: " . $ex->getMessage());
     }
 }