Permalink
Browse files

* Simplify field_settor subroutines with prepared query and placehol…

…ders.

	  Prevents infamous DBD::Pg::do errors.
  • Loading branch information...
1 parent ee2c111 commit 920e89905f0e73bc92c2c3887a74aa650e0020e4 @perusionmike perusionmike committed Dec 2, 2002
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/Vend/Table/DBI.pm
View
@@ -1,6 +1,6 @@
# Vend::Table::DBI - Access a table stored in an DBI/DBD database
#
-# $Id: DBI.pm,v 2.36 2002-10-27 04:18:33 mheins Exp $
+# $Id: DBI.pm,v 2.37 2002-12-02 22:14:22 mheins Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -20,7 +20,7 @@
# MA 02111-1307 USA.
package Vend::Table::DBI;
-$VERSION = substr(q$Revision: 2.36 $, 10);
+$VERSION = substr(q$Revision: 2.37 $, 10);
use strict;
@@ -1414,13 +1414,12 @@ sub row_hash {
sub field_settor {
my ($s, $column) = @_;
$s = $s->import_db() if ! defined $s->[$DBI];
+ my $q = "update $s->[$TABLE] SET $column = ? where $s->[$KEY] = ?";
+ my $sth = $s->[$DBI]->prepare($q)
+ or Carp::croak errmsg("Unable to prepare query for field_settor: %s", $q);
return sub {
my ($key, $value) = @_;
- $value = $s->quote($value)
- unless exists $s->[$CONFIG]{NUMERIC}{$column};
- $key = $s->quote($key)
- unless exists $s->[$CONFIG]{NUMERIC}{$s->[$KEY]};
- $s->[$DBI]->do("update $s->[$TABLE] SET $column=$value where $s->[$KEY] = $key");
+ $sth->execute($value, $key);
};
}

0 comments on commit 920e899

Please sign in to comment.