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 locally by using a delete query with a where clause.

ROLES

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

PROVIDED ATTRIBUTES

safe_mode

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

is rw
isa Bool
default 1

PROVIDED METHODS

b<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.

b<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 from programming 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 & LICENSE

Copyright (c) 2010-2012 Jeffrey Ray Hallock.

    This is free software, licensed under:

    The Artistic License 2.0 (GPL Compatible)
    

1 POD Error

The following errors were encountered while parsing the POD:

Around line 136:

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