[interchange-cvs] interchange - heins modified lib/Vend/Table/DBI.pm
interchange-core@interchange.redhat.com
interchange-core@interchange.redhat.com
Fri Nov 2 08:22:01 2001
User: heins
Date: 2001-11-02 13:21:01 GMT
Modified: lib/Vend/Table DBI.pm
Log:
* Add Stefan's bug fix with argument replacement.
* Add hash_query method which is convenient for me. Instead
of having to use:
$db->query({ sql => $query, hashref => 1});
you can just do $db->hash_query($query).
Revision Changes Path
2.4 +11 -3 interchange/lib/Vend/Table/DBI.pm
rev 2.4, prev_rev 2.3
Index: DBI.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Table/DBI.pm,v
retrieving revision 2.3
retrieving revision 2.4
diff -u -r2.3 -r2.4
--- DBI.pm 2001/10/29 20:47:39 2.3
+++ DBI.pm 2001/11/02 13:21:01 2.4
@@ -1,6 +1,6 @@
# Vend::Table::DBI - Access a table stored in an DBI/DBD database
#
-# $Id: DBI.pm,v 2.3 2001/10/29 20:47:39 jon Exp $
+# $Id: DBI.pm,v 2.4 2001/11/02 13:21:01 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -20,7 +20,7 @@
# MA 02111-1307 USA.
package Vend::Table::DBI;
-$VERSION = substr(q$Revision: 2.3 $, 10);
+$VERSION = substr(q$Revision: 2.4 $, 10);
use strict;
@@ -1501,11 +1501,19 @@
return sprintf $query, @$fields;
}
+sub hash_query {
+ my ($s, $query, $opt) = @_;
+ $opt ||= {};
+ $opt->{query} = $query;
+ $opt->{hashref} = 1;
+ return scalar $s->query($opt);
+}
+
sub query {
my($s, $opt, $text, @arg) = @_;
if(! CORE::ref($opt)) {
- unshift @arg, $text;
+ unshift @arg, $text if defined $text;
$text = $opt;
$opt = {};
}