[Jifty-commit] r973 - in Jifty-DBI/trunk: lib/Jifty/DBI
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue May 2 14:10:24 EDT 2006
Author: jesse
Date: Tue May 2 14:10:23 2006
New Revision: 973
Modified:
Jifty-DBI/trunk/ (props changed)
Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
Log:
r13148 at hualien: jesse | 2006-05-02 14:07:48 -0400
* We no longer do a count when setting up a collection's pager object by default
* order_by now returns the current orders
* added a "do_search" method to force a search, say before a count
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm Tue May 2 14:10:23 2006
@@ -415,6 +415,23 @@
return ($query_string);
}
+=head2 do_search
+
+C<Jifty::DBI::Collection> usually does searches "lazily". That is, it
+does a C<SELECT COUNT> or a C<SELELCT> on the fly the first time you ask
+for results that would need one or the other. Sometimes, you need to
+display a count of results found before you iterate over a collection,
+but you know you're about to do that too. To save a bit of wear and tear
+on your database, call C<do_search> before that C<count>.
+
+=cut
+
+sub do_search {
+ my $self = shift;
+ $self->_do_search() if $self->{'must_redo_search'};
+
+}
+
=head2 next
Returns the next row from the set as an object of the type defined by
@@ -929,17 +946,22 @@
The results would be unordered if method called without arguments.
+Returns the current list of columns.
+
=cut
sub order_by {
- my $self = shift;
+ my $self = shift;
+ if (@_) {
my @args = @_;
unless ( UNIVERSAL::isa( $args[0], 'HASH' ) ) {
- @args = {@args};
+ @args = {@args};
}
$self->{'order_by'} = \@args;
$self->redo_search();
+ }
+ return $self->{'order_by'};
}
=head2 _order_clause
@@ -1174,7 +1196,7 @@
@_
);
- $self->pager->total_entries( $self->count_all )
+ $self->pager #->total_entries( $self->count_all )
->entries_per_page( $args{'per_page'} )
->current_page( $args{'current_page'} );
More information about the Jifty-commit
mailing list