From 4102eb843ff11a4aae0cc890cf700b7e3b4e72e2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 2 Dec 2017 00:13:28 +0300 Subject: [PATCH] sql logger: pdo --- classes/logger/sql.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/classes/logger/sql.php b/classes/logger/sql.php index bd192ae7..f9f88aac 100644 --- a/classes/logger/sql.php +++ b/classes/logger/sql.php @@ -2,22 +2,19 @@ class Logger_SQL { function log_error($errno, $errstr, $file, $line, $context) { - if (Db::get() && get_schema_version() > 117) { + + $pdo = Db::pdo(); + + if ($pdo && get_schema_version() > 117) { - $errno = Db::get()->escape_string($errno); - $errstr = Db::get()->escape_string($errstr); - $file = Db::get()->escape_string($file); - $line = Db::get()->escape_string($line); - $context = DB::get()->escape_string($context); + $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null; - $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL"; - - $result = Db::get()->query( - "INSERT INTO ttrss_error_log + $sth = $pdo->prepare("INSERT INTO ttrss_error_log (errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES - ($errno, '$errstr', '$file', '$line', '$context', $owner_uid, NOW())"); + (?, ?, ?, ?, ?, ?, NOW())"); + $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]); - return Db::get()->affected_rows($result) != 0; + return $sth->rowCount(); } return false; -- 2.39.2