For more information... RTFM!
NAVIGATION
PAGES THAT LINK HERE
ACCOUNT LOGIN

You are not logged in

Powered by Interchange version 5.7.0

dbi_quote

This filter uses the Perl DBI/DBD quoting method to make strings safe for use in SQL queries.

All database-specific needs are honoured including, but not limited to, "\" escapes (if PostgreSQL or MySQL), truncating at the first ASCII NUL (if PostgreSQL) and turning an ASCII LF (line feed) into a literal two-character "\n" (if MySQL).

The first DefaultTables table will be used to provide a database connection handle, and database type, unless a table name is provided.

Note

Note

If you're using the [query] tag then you should use the [PREFIX-quote] sub-tag instead of this filter.

Availability

Availability

This filter was introduced in version 5.3.2, and is therefore not available for use with any earlier Interchange version.

Example

[filter dbi_quote]Kevin's cat[/filter]

Results in:

'Kevin\'s cat'

Source code

sub {
    my ($val, $tag, $table) = @_;

    $table ||= $Vend::Cfg->{ProductFiles}[0];

    my $db;
    unless ($db = dbref($table)) {
        ::logError("filter dbi_quote cannot find database handle for table '%s'", $table);
        return;
    }
    return $db->quote($val);
}

Category:  Filters
Last modified by: Kevin Walsh
Modification date: Wednesday 19 September 2007 at 4:57 PM (EDT)
Home  |  Legal nonsense  |  Privacy policy  |  Donations  |  Contact us