Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi all,

 

I used these forum long ago and I can no longer remember my login creds..... anyway this question isn't really about this book, but I felt it would go best in the "Quickpro" arena.

 

I'm wondering how you MVC users approach data handling. I'll create a simple scenario

 

- 3 Tables (a, b and c)

- Table a joins to table b which joins to table c

- I have a query which selects all "a" rows and how many "b" and "c" rows match each "a" row.

 

I steering clear of any ORM's for now and I'm using ->fetchObject in PDO mapping the data to the "a" model.

 

The Problem

 

The "a" model doesn't have an attribute for "total b rows" or "total c rows", is it ok by MVC law to store this data in the "a" object or should it be stored somewhere else, if so where?

 

Thanks for reading and hopefully replying

 

Simon

Share this post


Link to post
Share on other sites

Hey Simon,

 

Models don't have to map one-to-one to databases, especially when you're not using ORM. Your query is essentially creating a new data type and I would create a class that models it. That's my inclination given the information provided, at least.

  • Upvote 1

Share this post


Link to post
Share on other sites

Hi,

 

Hmm, do you mean as in a class that will store the object and the misc data around it? That could be the correct approach, I hate how sometimes programming strictly can make a task so long winded and convoluted.

 

Thanks for you views.

 

Simon

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...