Esteemed Monks,

After receiving the use ClassDBI mantra as a seemingly subliminal message from the monastery over some months I have now decided to try it. ne section of my major web-app is no complete and so I have some time to learn something new.

In fact object orientation is something new to this monk! I have written this subclass which I seem to be able to make work after a fashion.

package User; use Class::DBI::AsForm; use Class::DBI::Iterator; use base 'Class::DBI::mysql'; use strict; use warnings; __PACKAGE__->set_db('Main', 'DBI:mysql:appsys', 'root', ''); __PACKAGE__->set_up_table("ap_uprofile"); 1;
Now, in my run_mode I have this code:
my $self = shift; my $q = $self->query(); my $obj = User->search_like( 'upfirstname' => 'john%' ); print STDERR Dumper( $obj ); my @cols = $obj->columns; print STDERR Dumper ( @cols );
but I continually get told that the method columns cannot be found in Class::DBI::Iterator.

OK, so I am brain dead, but I just cannot seem to work out what is going on! Here is what I am trying to do:

  1. I search the table, and in this case I come up with 4 results. I want to print out a simple form that allows me to select one of the returned entries.
  2. I then want to retrieve the data for the selected record. Can I get this easily in a has (or hashref) that I can pass to HTML::Template to fill out the form fields?
  3. How do I get a count of how many records ( objects? ) are being returned?
I suspect that I am not use'ing the modules correctly. But the doc's are not aimed at neophytes :)

jdtoronto


In reply to Object Oriented Confusion! by jdtoronto

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.