Hi,

My job requires me to learn the Catalyst and DBIx mods and I have been going thru the metacpan Catalyst tutorial with its database as well as one of my own.

Now, my database is called music_library and has three tables - artists, albums, and songs. I am successfully viewing each table's contents on the browser, but using Table albums as an example, I do not want to look at field artist_id which is a foreign key in Table albums and the primary key in Table artists.

I want to see artist_name, another field in Table artists.

Now, Catalyst has the following text in file Album.pm in path music_library/lib/music_library/Schema/Result.

__PACKAGE__->add_columns( "album_id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0 } +, "album_name", { data_type => "text", is_nullable => 1 }, "artist_id", { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, "genre", { data_type => "text", is_nullable => 1 }, "source", { data_type => "text", is_nullable => 1 }, );

As well as:

__PACKAGE__->belongs_to( "artist", "music_library::Schema::Result::Artist", { artist_id => "artist_id" }, { is_deferrable => 0, join_type => "LEFT", on_delete => "NO ACTION", on_update => "NO ACTION", }, );

So the foreign key and left joins are defined.

Here are my questions:
1) What is the best way to enable viewing artist_name rather than artist_id?

2) Does the above code already make it so that the application "has" artist_name and it is just up to me to somehow correctly specify it in my Toolkit Template view file?

3) If it is not too much trouble, where does the cpan module definition indicate how to do what I want to do?

Thanks in advance!

Tony


In reply to Basic Catalyst/DBIx Question by o2bwise

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.