summaryrefslogtreecommitdiff
path: root/lib/TUWF/DB.pod
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2018-01-30 14:21:47 +0100
committerYorhel <git@yorhel.nl>2018-01-30 14:21:47 +0100
commitb39346c1d705194c19a77429bf4c6ca6393ea515 (patch)
treec26749999a3cb1a2d6aefec5a5768b23022801d6 /lib/TUWF/DB.pod
parentbd5d3665652d9e32b521b9eb1f5a820a7a697346 (diff)
Add dbVal()
Diffstat (limited to 'lib/TUWF/DB.pod')
-rw-r--r--lib/TUWF/DB.pod15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/TUWF/DB.pod b/lib/TUWF/DB.pod
index 0c6bde5..5982654 100644
--- a/lib/TUWF/DB.pod
+++ b/lib/TUWF/DB.pod
@@ -99,6 +99,17 @@ Example of an "UPDATE or INSERT" query:
Of course, the use of the extended formatting in the above example is not very
practical. Their advantage is more apparent when the queries get more dynamic.
+=head2 dbVal(query, @params)
+
+Accepts the same arguments as C<dbExec()>, and returns the first value of the
+first row.
+
+Examples:
+
+ my $count = tuwf->dbVal('SELECT COUNT(*) FROM users');
+
+ my $exists = tuwf->dbVal('SELECT 1 FROM users WHERE id = ?', $id);
+
=head2 dbRow(query, @params)
Accepts the same arguments as C<dbExec()>, and returns the first row of the
@@ -106,9 +117,7 @@ result as a hashref. The return value is equivalent to
C<$sth-E<gt>fetchrow_hashref()>, except C<dbRow()> returns an empty hash if the
query did not return any rows.
-Examples:
-
- my $count = tuwf->dbRow('SELECT COUNT(*) AS num FROM users')->{num};
+Example:
my %latest_announcement = %{ tuwf->dbRow(q{
SELECT title, message, post_date