[Dbix-class] patch: escaping user input - cookbook example
Carl Franks
fireartist at gmail.com
Wed Feb 6 10:34:09 GMT 2008
Here's a minor patch to address an issue that I found a solution for
in the list archives, but couldn't find in the docs anywhere.
It's against http://dev.catalyst.perl.org/repos/bast/DBIx-Class/0.08/trunk
if it should be against a different location and doesn't patch
cleanly, let me know and I'll fix it.
Cheers,
Carl
Index: lib/DBIx/Class/Manual/Cookbook.pod
===================================================================
--- lib/DBIx/Class/Manual/Cookbook.pod (revision 4038)
+++ lib/DBIx/Class/Manual/Cookbook.pod (working copy)
@@ -292,6 +292,21 @@
=end hidden
+=head2 Escaping user input
+
+If you need to insert user input into a string before passing it to
+L<DBIx::Class>: for example, to use the input string C<$query> in a
+wildcard search C<%$query%>, then use the following construction.
+
+ my $rs = $schema->resultset('Foo')->search(
+ {
+ name => \'LIKE ?',
+ },
+ {
+ bind => [ "%$query%", $query ],
+ }
+ );
+
=head1 JOINS AND PREFETCHING
=head2 Using joins and prefetch
More information about the DBIx-Class
mailing list