Use heredoc for SQL queries
This commit is contained in:
parent
76d7e75eb8
commit
94523eeba9
|
@ -14,21 +14,24 @@ sub new($class, $pg, $pg_object) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_posts($self) {
|
sub get_posts($self) {
|
||||||
$self->pg->db
|
$self->pg->db->query(<<~'END_SQL')->arrays()
|
||||||
->query('SELECT to_char(
|
SELECT to_char(message_date, 'Dy Mon DD HH:MI:SS AM TZ YYYY'),
|
||||||
message_date,
|
visitor_name,
|
||||||
\'Dy Mon DD HH:MI:SS AM TZ YYYY\'
|
message
|
||||||
),
|
|
||||||
visitor_name, message
|
|
||||||
FROM messages
|
FROM messages
|
||||||
ORDER BY message_date DESC;')->arrays()
|
ORDER BY message_date DESC;
|
||||||
|
END_SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
sub create_post($self, $name, $message) {
|
sub create_post($self, $name, $message) {
|
||||||
$self->pg->db->query(
|
$self->pg->db->query(
|
||||||
'INSERT INTO messages (message_date, visitor_name, message)
|
'INSERT INTO messages (message_date, visitor_name, message)
|
||||||
VALUES (NOW(), ?, ?);', $name, $message
|
VALUES (NOW(), ?, ?);', $name, $message
|
||||||
)
|
);
|
||||||
|
$self->pg-db->query(<<~'END_SQL', $name, $message);
|
||||||
|
INSERT INTO messages (message_date, visitor_name, message)
|
||||||
|
VALUES (NOW(), ?, ?);
|
||||||
|
END_SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
sub view_posts($self, $this_page, $last_page = undef, @posts) {
|
sub view_posts($self, $this_page, $last_page = undef, @posts) {
|
||||||
|
|
Loading…
Reference in a new issue