in reply to Building an index for next/last in a photo album.
Sounds rather complicated to me. If it's not too much of a hassle, I would suggest that you redesign your database to use img_id as the primary key (assuming that it is unique). You could then easily calculate the before and after img_id values and select them from the database in 1 SQL query. (It would also be very quick since primary keys are indexed)
davidj
Then the SQL query (something like):my ($img_id) = $str =~ m/img_id=(\d+)/; my $prev_id = $img_id - 1; my $next_id = $img_id + 1;
Hope this helps,"select WHATEVER from TABLE where img_id in ($prev_id, $img_id, $next_ +id)"
davidj
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Building an index for next/last in a photo album.
by Seumas (Curate) on Jul 26, 2004 at 20:46 UTC | |
by davidj (Priest) on Jul 26, 2004 at 21:29 UTC |
In Section
Seekers of Perl Wisdom