From 9bd6fe0e5f690970c49ee993e5012bef5868d9ab Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Thu, 18 Nov 2021 14:45:16 -0500 Subject: Add `created_at` field to DB --- src/clog.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/clog.c') diff --git a/src/clog.c b/src/clog.c index c853fd3..0f3b708 100644 --- a/src/clog.c +++ b/src/clog.c @@ -42,8 +42,7 @@ page(struct http_request *req) int row, rows; // Results - char *id; - char *title, *body; + char *id, *title, *created_at, *body; /* req->status = HTTP_STATUS_INTERNAL_ERROR; */ @@ -67,7 +66,7 @@ page(struct http_request *req) * Now we can fire off the query, once it returns we either have * a result on which we can operate or an error occurred. */ - if (!kore_pgsql_query(&sql, "SELECT id, title, body FROM entries ORDER BY id ASC;")) { + if (!kore_pgsql_query(&sql, "SELECT id, title, created_at, body FROM posts ORDER BY id ASC;")) { kore_pgsql_logerror(&sql); goto out; } @@ -78,7 +77,8 @@ page(struct http_request *req) id = kore_pgsql_getvalue(&sql, row, 0); title = kore_pgsql_getvalue(&sql, row, 1); - body = kore_pgsql_getvalue(&sql, row, 2); + created_at = kore_pgsql_getvalue(&sql, row, 2); + body = kore_pgsql_getvalue(&sql, row, 3); kore_log(LOG_NOTICE, "id: '%s'; title '%s'", id, title); struct kore_buf *html_buf = kore_buf_alloc(4096); @@ -93,6 +93,7 @@ page(struct http_request *req) resp_buf, (const char *) asset_post_html, title, + created_at, kore_buf_stringify(html_buf, NULL) ); -- cgit v1.2.3