Am 2011-06-16 19:27, schrieb dorian taylor:
On Thu, Jun 16, 2011 at 10:17 AM, Peter Rabbitson<[email protected]> wrote:
This won't be wrong - ->count returns how many objects you would receive
via ->all/->next. If you want full count of the underlying source with
all limits removed - keep the original resultset around. If you do not care
about WHERE conditions either - $rs->result_source->resultset->count will
do it for you.
Except it is wrong:
my $rs = $db->resultset('Employee::Job')->search(
{ period => '2010-02-28' },
{
rows => 100,
offset => 100,
}
);
print $rs->count; # 100, the number I'm looking for is 2023
So what it looks like I want to do is like you suggested, clone the
ResultSet and either get the WHERE clause out of the original or
remove the rows/offset attributes and/or add them in later. I just
don't see anything in the class's interface that will let me do that.
Thanks,
You've limited the resultset to 100 rows, of course count will return
100 or less!
What Peter told you is to keep an unrestricted resultset around:
my $rs_unrestricted = $db->resultset('Employee::Job')->search_rs({
period => '2010-02-28',
});
my $rs_restricted = $rs_unrestricted->search_rs(undef, {
rows => 100,
offset => 100,
});
Now you can do $rs_unrestricted->count;
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be
privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]