Changeset 1001

Show
Ignore:
Timestamp:
02/19/04 19:01:07
Author:
miyagawa
Message:

0.03

Files:

Legend:

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

    r907 r1001  
    11Revision history for Perl extension Class::DBI::AbstractSearch 
     2 
     30.03  Thu Feb 19 19:00:53 JST 2004 
     4        - Fixed some typos. 
     5          (Thanks to Jay Strauss) 
     6        * Added support for SQL::Abstract->new() option 
     7          (Thanks to darren chamberlain) 
    28 
    390.02  Mon Jun 30 10:37:15 2003 
    410        - modified input parameters for 'search_where' to accept 
    511          an optional %attrs hash ref. 
    6           (Thanks to Aaron Startup Cope) 
     12          (Thanks to Aaron Straup Cope) 
    713 
    8140.01  Tue Feb  4 23:33:46 2003 
  • Class-DBI-AbstractSearch/trunk/lib/Class/DBI/AbstractSearch.pm

    r907 r1001  
    33use strict; 
    44use vars qw($VERSION @EXPORT); 
    5 $VERSION = 0.02
     5$VERSION = 0.03
    66 
    77require Exporter; 
     
    1515    my $where = (ref $_[0]) ? $_[0]          : { @_ }; 
    1616    my $attr  = (ref $_[0]) ? $_[1]          : undef; 
    17     my $order = ($attr)     ? $attr->{order} : undef; 
     17    my $order = ($attr)     ? delete($attr->{order}) : undef; 
    1818 
    1919    $class->can('retrieve_from_sql') or do { 
     
    2121        Carp::croak("$class should inherit from Class::DBI >= 0.90"); 
    2222    }; 
    23     my $sql = SQL::Abstract->new; # XXX how do we supply options here? 
    24     my($where, @bind) = $sql->where($where,$order); 
    25     $where =~ s/^\s*WHERE\s*//i; 
    26     return $class->retrieve_from_sql($where, @bind); 
     23    my $sql = SQL::Abstract->new(%$attr); 
     24    my($phrase, @bind) = $sql->where($where, $order); 
     25    $phrase =~ s/^\s*WHERE\s*//i; 
     26    return $class->retrieve_from_sql($phrase, @bind); 
    2727} 
    2828 
     
    3939  use Class::DBI::AbstractSearch; 
    4040 
    41   pacage main; 
     41  package main; 
    4242  my @music = CD::Music->search_where( 
    4343      artist => [ 'Ozzy', 'Kelly' ], 
     
    6565  $class->search_where(%where); 
    6666 
    67 Takes hash to specify WHERE clause. See L<SQL::Abstract> for hash 
     67Takes a hash to specify WHERE clause. See L<SQL::Abstract> for hash 
    6868options. 
    6969 
    7070  $class->search_where(\%where,\%attrs); 
    7171 
    72 Takes hash reference to specify WHERE clause. See L<SQL::Abstract>  
     72Takes hash reference to specify WHERE clause. See L<SQL::Abstract> 
    7373for hash options. Takes a hash reference to specify additional query 
    74 attributes. Valid attributes are
     74attributes. Class::DBI::AbstractSearch uses these attributes
    7575 
    7676=over 4 
     
    8585=back 
    8686 
     87Any other attributes are passed to the SQL::Abstract constructor, 
     88and can be used to control how queries are created.  For example, 
     89to use 'AND' instead of 'OR' by default, use: 
     90 
     91    $clsas->search_where(\%where, { logic => 'AND' }); 
     92 
    8793=head1 AUTHOR 
    8894 
    8995Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt> with some help from 
    90 cdbi-talk maling list, especially: 
     96cdbi-talk mailing list, especially: 
    9197 
    9298  Tim Bunce