[Dbix-class] Search and Delete with Single Query

Will Crawford billcrawford1970 at gmail.com
Thu Aug 28 12:08:04 GMT 2014


$schema->resultset('User')->search({GroupId => 712})->delete;

On 28 August 2014 13:01, Sheeju Alex <sheejuec7 at gmail.com> wrote:
> Hi All,
>
>     Is there any way in DBIx to delete all rows from resultset in a single
> query, it looks like delete and delete_all will delete the resultset row by
> row.
>
> my $rs = $schema->resultset('User')->search({GroupId => 712});
> $rs->delete_all;
>
> If there are 100 Users in User table then the above statement will delete in
> 100 query instead is there a way to delete in single query.
>
> DELETE FROM User WHERE GroupId = 712;
>
>
> Best Regards,
> Sheeju Alex
>
> _______________________________________________
> 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



More information about the DBIx-Class mailing list