From dae047615914e985a5ed7fdf2616db58d09168c9 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Mar 2021 09:58:50 +0300 Subject: [PATCH] sql logger: use orm --- classes/logger/sql.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/classes/logger/sql.php b/classes/logger/sql.php index d21934aa6..cf77a1896 100755 --- a/classes/logger/sql.php +++ b/classes/logger/sql.php @@ -36,12 +36,19 @@ class Logger_SQL implements Logger_Adapter { // this would cause a PDOException on insert below $owner_uid = !empty($_SESSION["uid"]) ? $_SESSION["uid"] : null; - $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log - (errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES - (?, ?, ?, ?, ?, ?, NOW())"); - $sth->execute([$errno, $errstr, $file, (int)$line, $context, $owner_uid]); + $entry = ORM::for_table('ttrss_error_log')->create(); - return $sth->rowCount(); + $entry->set([ + 'errno' => $errno, + 'errstr' => $errstr, + 'filename' => $file, + 'lineno' => (int)$line, + 'context' => $context, + 'owner_uid' => $owner_uid, + 'created_at' => Db::NOW(), + ]); + + return $entry->save(); } return false;