Skip to content

Commit 93f9db0

Browse files
committed
Fix data types in NewsPost::save()
1 parent 209208c commit 93f9db0

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/libraries/NewsPost.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,22 @@ public function save() {
408408
LIMIT 1;
409409
");
410410
$stmt->bindParam(":category_id", $this->category_id, PDO::PARAM_INT);
411-
$stmt->bindParam(":content", $this->content, PDO::PARAM_INT);
412-
$stmt->bindParam(":created_dt", $this->created_datetime, PDO::PARAM_INT);
411+
$stmt->bindParam(":content", $this->content, PDO::PARAM_STR);
412+
$stmt->bindParam(":created_dt", $this->created_datetime, PDO::PARAM_STR);
413413
$stmt->bindParam(":edited_count", $this->edited_count, PDO::PARAM_INT);
414-
$stmt->bindParam(":edited_dt", $this->edited_datetime, PDO::PARAM_INT);
414+
if (is_null($this->edited_datetime)) {
415+
$stmt->bindParam(":edited_dt", null, PDO::PARAM_NULL);
416+
} else {
417+
$stmt->bindParam(":edited_dt", $this->edited_datetime, PDO::PARAM_STR);
418+
}
415419
$stmt->bindParam(":id", $this->id, PDO::PARAM_INT);
416420
$stmt->bindParam(":options", $this->options_bitmask, PDO::PARAM_INT);
417-
$stmt->bindParam(":title", $this->title, PDO::PARAM_INT);
418-
$stmt->bindParam(":user_id", $this->user_id, PDO::PARAM_INT);
421+
$stmt->bindParam(":title", $this->title, PDO::PARAM_STR);
422+
if (is_null($this->user_id)) {
423+
$stmt->bindParam(":user_id", null, PDO::PARAM_NULL);
424+
} else {
425+
$stmt->bindParam(":user_id", $this->user_id, PDO::PARAM_INT);
426+
}
419427
if (!$stmt->execute()) {
420428
throw new QueryException("Cannot save news post");
421429
}

0 commit comments

Comments
 (0)