Email change on user
This commit is contained in:
@@ -118,6 +118,10 @@ class Post implements JsonSerializable
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
|
||||
$db->beginTransaction();
|
||||
|
||||
$failed = [];
|
||||
$reason = [];
|
||||
if (!empty($content)) {
|
||||
$content = substr(trim($content), 0, 250);
|
||||
|
||||
@@ -125,11 +129,25 @@ class Post implements JsonSerializable
|
||||
$stmt->bindValue(":CON", nl2br(htmlspecialchars($content)));
|
||||
$stmt->bindValue(":ID", $this->id);
|
||||
try {
|
||||
if (!$stmt->execute()) throw ApiError::failedUpdate(["content"]);
|
||||
if (!$stmt->execute()) {
|
||||
$failed = ["content"];
|
||||
$reason = ["generic"];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw ApiError::failedUpdate(["content"]);
|
||||
$failed = ["content"];
|
||||
if ($e->getCode() === "23000") {
|
||||
$pdoErr = $stmt->errorInfo()[1];
|
||||
$reason = ["SQL: $pdoErr"];
|
||||
} else $reason = ["{$e->getCode()}"];
|
||||
}
|
||||
}
|
||||
if ($failed !== null) {
|
||||
$db->rollBack();
|
||||
|
||||
throw ApiError::failedUpdate($failed, $reason);
|
||||
}
|
||||
|
||||
$db->commit();
|
||||
|
||||
return Post::getByID($this->id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user