Changeset 907

Show
Ignore:
Timestamp:
07/11/03 12:46:43
Author:
miyagawa
Message:

0.02

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Class-DBI-AbstractSearch/trunk/Changes

    r833 r907  
    11Revision history for Perl extension Class::DBI::AbstractSearch 
     2 
     30.02  Mon Jun 30 10:37:15 2003 
     4        - modified input parameters for 'search_where' to accept 
     5          an optional %attrs hash ref. 
     6          (Thanks to Aaron Startup Cope) 
    27 
    380.01  Tue Feb  4 23:33:46 2003 
  • Class-DBI-AbstractSearch/trunk/lib/Class/DBI/AbstractSearch.pm

    r833 r907  
    33use strict; 
    44use vars qw($VERSION @EXPORT); 
    5 $VERSION = 0.01
     5$VERSION = 0.02
    66 
    77require Exporter; 
     
    1212 
    1313sub search_where { 
    14     my($class, %where) = @_; 
     14    my $class = shift; 
     15    my $where = (ref $_[0]) ? $_[0]          : { @_ }; 
     16    my $attr  = (ref $_[0]) ? $_[1]          : undef; 
     17    my $order = ($attr)     ? $attr->{order} : undef; 
     18 
    1519    $class->can('retrieve_from_sql') or do { 
    1620        require Carp; 
     
    1822    }; 
    1923    my $sql = SQL::Abstract->new; # XXX how do we supply options here? 
    20     my($where, @bind) = $sql->where(\%where); 
     24    my($where, @bind) = $sql->where($where,$order); 
    2125    $where =~ s/^\s*WHERE\s*//i; 
    2226    return $class->retrieve_from_sql($where, @bind); 
     
    4145  ); 
    4246 
     47  my @misc = CD::Music->search_where( 
     48      { artist => [ 'Ozzy', 'Kelly' ], 
     49        status => { '!=', 'outdated' } }, 
     50      { order  => "reldate DESC" }); 
     51 
    4352=head1 DESCRIPTION 
    4453 
     
    5665  $class->search_where(%where); 
    5766 
    58 takes hash to specify WHERE clause. See L<SQL::Abstract> for hash 
     67Takes hash to specify WHERE clause. See L<SQL::Abstract> for hash 
    5968options. 
     69 
     70  $class->search_where(\%where,\%attrs); 
     71 
     72Takes hash reference to specify WHERE clause. See L<SQL::Abstract>  
     73for hash options. Takes a hash reference to specify additional query 
     74attributes. Valid attributes are : 
     75 
     76=over 4 
     77 
     78=item * 
     79 
     80B<order> 
     81 
     82Array reference of fields that will be used to order the results of 
     83your query. 
     84 
     85=back 
    6086 
    6187=head1 AUTHOR