From 27187eda2cb3b015b0e432fb559b01e2d1e14beb Mon Sep 17 00:00:00 2001 From: hylom Date: Sun, 30 Oct 2016 20:55:13 +0900 Subject: [PATCH] Model::Comments: now 'select' method returns Hash, not Array of Hash --- src/newslash_web/lib/Newslash/Model/Comments.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/newslash_web/lib/Newslash/Model/Comments.pm b/src/newslash_web/lib/Newslash/Model/Comments.pm index a8de273b..c590b38a 100644 --- a/src/newslash_web/lib/Newslash/Model/Comments.pm +++ b/src/newslash_web/lib/Newslash/Model/Comments.pm @@ -76,8 +76,11 @@ EOSQL if (!$comments) { $dbh->disconnect(); return undef; - } + } + if ($query_type eq 'cid') { + return $comments->[0]; + } if ($query_type eq 'discussion_id') { my $root = $self->build_comment_tree($comments); } @@ -175,6 +178,7 @@ sub create { $params->{pid} ||= 0; if ($params->{pid}) { my $parent = $self->select(cid => $params->{pid}); + if (!$parent) { $self->set_error("parent comment not exists", 100); return; -- 2.11.0