From fe95d448e35ee6608f7e5f3611bdb6de861e9826 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Tue, 22 Aug 2017 17:24:30 +1000 Subject: [PATCH] * CMTD::Helpers : sql helpers --- lib/CMTD/Helpers.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/CMTD/Helpers.pm b/lib/CMTD/Helpers.pm index 67192c6..ba0ff3e 100644 --- a/lib/CMTD/Helpers.pm +++ b/lib/CMTD/Helpers.pm @@ -58,6 +58,20 @@ sub register { $c->app->log->error($@); }; }); + + $app->helper(sid_by_name => sub { + my ($c, $site) = @_; + return $self->app->db->select('sites', 'id', {site => $site})->list; + }); + + $app->helper(pid_by_hash => sub { + my ($c, $sid, $hash) = @_; + return $self->app->db->select('pages', 'id', {sid => $sid, hash => $hash})->list; + }); + $app->helper(comments_by_pid => sub { + my ($c, $pid) = @_; + return $self->app->db->select('comments', '*', {pid => $sid}, 'seq')->hashes; + }); } 1;