Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: DBI Row Limiting

by ccn (Vicar)
on Sep 14, 2004 at 18:04 UTC ( [id://390928]=note: print w/replies, xml ) Need Help??


in reply to DBI Row Limiting

You can override fetchall_arrayref method.

Just create dbilimit.pl

use strict; package DBI; my $fetchall_arrayref; our $ROWS_LIMIT; INIT { $ROWS_LIMIT = 10; $fetchall_arrayref = \&fetchall_arrayref; } no warnings; sub fetchall_arrayref { my ($sth, $slice, $max_rows) = @_; $max_rows = $ROWS_LIMIT unless defined $max_rows; $fetchall_arrayref->($sth, $slice, $max_rows); } 1;
and require it after use DBI; line

P.S. the code is not tested so it may have some bugs

Replies are listed 'Best First'.
Re^2: DBI Row Limiting
by ketema (Scribe) on Sep 14, 2004 at 18:29 UTC
    This what I was looking for! I didn't want to have to re-write every instance of a fetchall_arrayref or hashref in the code to a while fetch loop, that would have chaned the logic pf the program. Overridding the methods in this manner is much more concise and easier. Thank you, it did the job.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://390928]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-24 22:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found