The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

StormX::Query::DeleteWhere - A delete query with a where clause

SYNOPSIS

    use Storm;

    use StormX::Query::DeleteWhere;

    $storm = Storm->new( ... );
    
    $q = StormX::Query::DeleteWhere->new( $storm, 'My::Object::Class' );

    $q->where( '.expired', '<=', '?' );

    $q->delete( '2012-12-21' );

DESCRIPTION

Delete objects that you do not have instantiated on your machine by using a query with a where clause.

ROLES

Storm::Role::Query::HasBindParams
Storm::Role::Query::HasWhereClause
Storm::Role::Query::IsExecutable

PROVIDED ATTRIBUTES

safe_mode
is: rw
isa: Bool
default: 1
writer: set_safe_mode
reader: safe_mode

This attribute must be set to true to delete all records from a table in a single query.

PROVIDED METHODS

new $storm, $class, [@params]

This method instantiates a new StormX::Query::DeleteWhere query. $storm is the Storm instance to operate on, and $class is the class of objects you wish to delete from the database. Both $storm and <$class> are required. Any additional paramaters will be used to query attributes.

delete [@args]

Execute the query, deleting objects from the database. If the where clause of your query used placholders ('?'), they will be replaced with the @args supplied.

WHERE CLAUSE

The following methods are provided via Storm::Role::Query::HasWhereClause. Read Storm::Tutorial for more information on how to use these methods.

where
and
or
group_start
group_end

SAFE MODE

By default, StormX::Query::DeleteWhere queries are in "safe-mode". This is to safequard your data fromprogramming errors.

The following query has no where clause. If ran, it will produce an error instead of deleting all the objects in the table. (Which is what would happen with an SQL delete query with no where clause.)

    $q = StormX::Query::DeleteWhere->new( $storm, 'My::Object::Class' );

    $q->delete;

You may disable "safe_mode" and enable clearing of all records from a table like this:

    $q = StormX::Query::DeleteWhere->new( $storm, 'My::Object::Class', safe_mode => 0 );

or

    $q = StormX::Query::DeleteWhere->new( $storm, 'My::Object::Class' );

    $q->set_safe_mode( 0 );

AUTHORS

Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>

COPYRIGHT

    Copyright (c) 2011 Jeffrey Ray Hallock
    
    All rights reserved. This program is free software; you can redistribute it
    and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 142:

You forgot a '=back' before '=head2'