[interchange-cvs] interchange - jon modified 2 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Tue Oct 4 15:31:27 EDT 2005

User:      jon
Date:      2005-10-04 19:31:27 GMT
Modified:  .        MANIFEST
Added:     code/Filter dbi_quote.filter
Add dbi_quote filter, which uses DBI's (or the DBD's, if it overrides)
quote method to make a string safe to use in SQL. It takes into account
any database-specific quoting needs (such as \ for PostgreSQL or MySQL,
truncating at the first \0 for PostgreSQL, turning a newline into a
literal two-character '\n' for MySQL, etc.).

The database handle used is that of the first ProductFiles database,
unless another is specified with e.g.:

    [filter dbi_quote.inventory]some string or other[/filter]

Which is likely to result in:

    'some string or other'

Note the containing quotes, which is different than Interchange's native
"sql" filter. See also the DBI man page details about the quote method.

Since this uses database handles, Safe must be considered if it's being
used via the $Tag object in a Perl block.

Revision  Changes    Path
1.1                  interchange/code/Filter/dbi_quote.filter

rev 1.1, prev_rev 1.0
Index: dbi_quote.filter
# Copyright 2005 Interchange Development Group (http://www.icdevgroup.org/)
# Licensed under the GNU GPL v2. See file LICENSE for details.
# $Id: dbi_quote.filter,v 1.1 2005/10/04 19:31:27 jon Exp $

CodeDef dbi_quote Filter
CodeDef dbi_quote Description SQL quoting using DBI
CodeDef dbi_quote Routine <<EOR
sub {
	my $val = shift;
	shift;  # get rid of tag
	my $table = shift || $Vend::Cfg->{ProductFiles}[0];
	my $db = dbref($table) or do {
		::logError("filter dbi_quote couldn't find dbref for table '%s'", $table);
	return $db->quote($val);

2.173     +1 -0      interchange/MANIFEST

rev 2.173, prev_rev 2.172
RCS file: /var/cvs/interchange/MANIFEST,v
retrieving revision 2.172
retrieving revision 2.173
diff -u -u -r2.172 -r2.173
--- MANIFEST	19 Sep 2005 14:30:04 -0000	2.172
+++ MANIFEST	4 Oct 2005 19:31:27 -0000	2.173
@@ -14,6 +14,7 @@

More information about the interchange-cvs mailing list