Skip to content

Commit

Permalink
Fix null values on UserProfile when saving
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbennett committed Feb 12, 2019
1 parent 46c30db commit 7c1f3ba
Showing 1 changed file with 69 additions and 11 deletions.
80 changes: 69 additions & 11 deletions src/libraries/UserProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,21 +323,79 @@ public function save() {
`user_id` = :user_id,
`website` = :website
;');
$stmt->bindParam(':bio', $this->biography, PDO::PARAM_STR);
$stmt->bindParam(':discord', $this->discord_username, PDO::PARAM_STR);
$stmt->bindParam(':fb', $this->facebook_username, PDO::PARAM_STR);
$stmt->bindParam(':github', $this->github_username, PDO::PARAM_STR);
$stmt->bindParam(':ig', $this->instagram_username, PDO::PARAM_STR);
$stmt->bindParam(':ph', $this->phone, PDO::PARAM_STR);
$stmt->bindParam(':reddit', $this->reddit_username, PDO::PARAM_STR);
$stmt->bindParam(':skype', $this->skype_username, PDO::PARAM_STR);
$stmt->bindParam(':steam', $this->steam_id, PDO::PARAM_STR);
$stmt->bindParam(':twitter', $this->twitter_username, PDO::PARAM_STR);

if (is_null($this->biography)) {
$stmt->bindParam(':bio', $this->biography, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':bio', $this->biography, PDO::PARAM_STR);
}

if (is_null($this->discord_username)) {
$stmt->bindParam(':discord', $this->discord_username, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':discord', $this->discord_username, PDO::PARAM_STR);
}

if (is_null($this->facebook_username)) {
$stmt->bindParam(':fb', $this->facebook_username, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':fb', $this->facebook_username, PDO::PARAM_STR);
}

if (is_null($this->github_username)) {
$stmt->bindParam(':github', $this->github_username, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':github', $this->github_username, PDO::PARAM_STR);
}

if (is_null($this->instagram_username)) {
$stmt->bindParam(':ig', $this->instagram_username, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':ig', $this->instagram_username, PDO::PARAM_STR);
}

if (is_null($this->phone)) {
$stmt->bindParam(':ph', $this->phone, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':ph', $this->phone, PDO::PARAM_STR);
}

if (is_null($this->reddit_username)) {
$stmt->bindParam(':reddit', $this->reddit_username, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':reddit', $this->reddit_username, PDO::PARAM_STR);
}

if (is_null($this->skype_username)) {
$stmt->bindParam(':skype', $this->skype_username, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':skype', $this->skype_username, PDO::PARAM_STR);
}

if (is_null($this->steam_id)) {
$stmt->bindParam(':steam', $this->steam_id, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':steam', $this->steam_id, PDO::PARAM_STR);
}

if (is_null($this->twitter_username)) {
$stmt->bindParam(':twitter', $this->twitter_username, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':twitter', $this->twitter_username, PDO::PARAM_STR);
}

$stmt->bindParam(':user_id', $this->user_id, PDO::PARAM_INT);
$stmt->bindParam(':website', $this->website, PDO::PARAM_STR);

if (is_null($this->website)) {
$stmt->bindParam(':website', $this->website, PDO::PARAM_NULL);
} else {
$stmt->bindParam(':website', $this->website, PDO::PARAM_STR);
}

if (!$stmt->execute()) {
throw new QueryException('Cannot save user profile');
}

$stmt->closeCursor();

$object = new StdClass();
Expand Down

0 comments on commit 7c1f3ba

Please sign in to comment.