[Dbix-class] bind parameter syntax for an array
William Piel
william.piel at yale.edu
Wed Mar 28 15:40:25 GMT 2012
Hi all,
I'd like to create a custom ResultSource query that uses "IN" in the SQL. H=
ow can I use the bind parameters so that I can pass an array to provide the=
contents for IN(=85) ? The below example works so long as @my_array has =
only one element -- beyond that I get a mismatch in the number of placehold=
ers. Passing it \@my_array does not work. =
thanks,
Bill
package My::Schema::Result::TableT;
use strict;
use warnings;
use base qw/DBIx::Class::Core/;
__PACKAGE__->table_class('DBIx::Class::ResultSet::View');
__PACKAGE__->result_source_instance->is_virtual(1);
__PACKAGE__->result_source_instance->view_definition(q[
SELECT t.x, t.y, t.z
FROM table t
WHERE t.a =3D ?
AND t.b IN (?);
]);
my $results =3D $schema->resultset( 'TableT' )->search( {}, { bind =3D> [ =
$my_scalar, @my_array ]} );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120328/8b7=
3b17a/attachment.htm
More information about the DBIx-Class
mailing list