Hey all,
This is probably an ignorant question, but I'm having some trouble with Class::DBI retrieving all of the requested records from my database.
## index.cgi #!perl -w use strict; use PL; my $obj = PL->new; my @info = $obj->DBI->Entries->retrieve_from_sql(qq{ hidden = "n" ORDER BY date desc LIMIT 5 }); my %data; my @loop_data = (); ## NOT INCREMENTING PRIMARY KEY, THUS RETURNING THE FIRST ROW *TWICE* for (@info) { $data{author} = $_->author; $data{content} = $_->content; $data{title} = $_->title; $data{id} = $_->id; $data{date} = $_->date; push @loop_data, \%data; } my %content = ( title=>'Devin\'s Journal v.9', body=>\@loop_data, # CRITICAL: must + be arrayref containing hashref, # DBI should be $s +th->fetchrow_arrayref({}); search=>'search?q=', #to be defined in +Config.pm referer => $ENV{'REFERER'} ? $ENV{'REFERER'} : "none", IPAddy => $ENV{'REMOTE_ADDR'} ); $obj->Template->file ("tmpl/main.tmpl"); print $obj->Template->format ( \%content ); ## PL::DBI::Entries.pm package PL::DBI::Entries; use strict; use base 'PL::DBI'; sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } __PACKAGE__->columns( Primary => qw[id] ); __PACKAGE__->columns( All => qw [ id author title date content ip ] ); __PACKAGE__->table('entries'); 1;
It's retrieving two results, but it's the first record TWICE. What's going on here?
meh.

janitored by ybiC: Retitle from "Class::DBI" because one-word-node-titles hinder site search


In reply to Duplicate rows with Class::DBI by stonecolddevin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.