Proper Use of the DB

Permalink
I'm creating a package and blocks to create and display a list of press releases we've posted to industry news sites. The end goal is a list of external links, ordered by date, to each press release.

Should I create a new table to manage my links or use attributes or a combination of both?

My conclusion thus far is that the links do not belong in a block type table as those seem to map one record to a block instance and just hold parameters for that block (rather than a list of records to be displayed within the block, which is my end goal).

 
ryan replied on at Permalink Reply
ryan
You may want to add a related table for your links, then use the block to display those links, optionally with filter/sort options.

You can define the table either in your package's db.xml file, or the block's.

Then create a /model file with a class that extends the DatabaseItemList class and use that to select/filter your links - you'd get pagination, sorting etc. with very little work using that.

I wouldn't use attributes unless you were going to create pages for each entry.
mikestitch replied on at Permalink Reply
Thanks Ryan. That would also imply a model class to represent a single prlink correct? I'm assuming a model would be the way to create a new prlink from a form post.

If so, the question I have there is what class should I extend for the individual prlink? Looks like most everything in the model layer extends Object but some things extend Model.
ScottC replied on at Permalink Reply
ScottC
extending object is fine, extending model gets you a little bit of activeRecord stuff in there so you don't need to write full-blown SQL for everything and you can use find methods and things like that.

All of the add-ons I write(for now) extend object, It doesn't hurt to extend model but at that point you might want to just extend ADODB activerecord(not sure on the exact name) to get code completion on the methods available.

Extending object gives you a setPropertiesFromArray method which is useful for a $db->getRow() call or something along those lines.
mikestitch replied on at Permalink Reply
Hi Ryan,

Just checking to see if you or anyone else had some input on my follow-up question.
Mnkras replied on at Permalink Reply
Mnkras
tiny comment, model extends object,
jshannon replied on at Permalink Reply
jshannon
It seems that
"* Concrete Model Class
* The model class extends the ADOdb active record class, allowing items that inherit from it to use the automatic create, updating, read and delete functionality it provides.
".

I came across this thread today because I'm trying to figure out which one to use. I'm leaning toward Model, but it'd be nice if there was one consistent one -- maybe if the core Object extended active record...