StormX::Query::DeleteWhere - A delete query with a where clause
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' );
Delete objects that you do not have instantiated locally by using a delete query with a where clause.
This attribute must be set to true to delete all records from a table in a single query.
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.
$storm
$class
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.
@args
The following methods are provided via Storm::Role::Query::HasWhereClause. Read Storm::Tutorial for more information on how to use these methods.
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 );
Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>
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:
You forgot a '=back' before '=head2'
To install StormX::Query::DeleteWhere, copy and paste the appropriate command in to your terminal.
cpanm
cpanm StormX::Query::DeleteWhere
CPAN shell
perl -MCPAN -e shell install StormX::Query::DeleteWhere
For more information on module installation, please visit the detailed CPAN module installation guide.