[Dbix-class] bind parameter syntax for an array
Alexander Hartmaier
alexander.hartmaier at t-systems.at
Thu Mar 29 15:23:03 GMT 2012
Why are you defining this as a virtual view instead of just having a result=
class for the table and adding a method to its resultset class?
BR, Alex
Am 2012-03-28 17:40, schrieb William Piel:
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(...) ? 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 ]} );
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co=
.uk
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*
Notice: This e-mail contains information that is confidential and may be pr=
ivileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120329/816=
48992/attachment.htm
More information about the DBIx-Class
mailing list