Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Where Does This Fall in the MVC Architecture?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tony Thomas  
View profile  
 More options Dec 9 2008, 9:35 am
From: Tony Thomas <truet...@gmail.com>
Date: Tue, 9 Dec 2008 06:35:59 -0800 (PST)
Local: Tues, Dec 9 2008 9:35 am
Subject: Where Does This Fall in the MVC Architecture?
I'm working on an application to store information on lab specimens.
The lab receive specimens which are divided into aliquots which are
then put into boxes and in turn stored in freezers.

I want to create a function to find all unstored aliquots and display
a message on every page to alert the lab users that there are aliquots
that haven't been assigned to boxes yet. It's a simple query:

SELECT COUNT(aliquot.id)
FROM aliquots
WHERE aliquots.box_id IS NULL

The problem is that I can't quite decide where it belongs in the MVC
architecture. It seems like a helper since the alert message would
appear in the left column of every page. But it runs a query, so does
it belong in a model? The problem is that I want to retrieve the
information no matter which model is currently in use.

What's the best way to preserve the MCV structure and DRY philosophy
while including a function like this in my application?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon Bennett  
View profile  
 More options Dec 9 2008, 10:29 am
From: "Jon Bennett" <jmbenn...@gmail.com>
Date: Tue, 9 Dec 2008 15:29:16 +0000
Local: Tues, Dec 9 2008 10:29 am
Subject: Re: Where Does This Fall in the MVC Architecture?
Hi Tony,

I would:

* create a method in your model to fetch the data
* create a method in your controller to access this data
* create an element that calls via 'requestAction' the data from the controller
* insert this element into your layout and add array('cache'=>'1 hour');

hth

jon

--

jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon Bennett  
View profile  
 More options Dec 9 2008, 10:30 am
From: "Jon Bennett" <jmbenn...@gmail.com>
Date: Tue, 9 Dec 2008 15:30:18 +0000
Local: Tues, Dec 9 2008 10:30 am
Subject: Re: Where Does This Fall in the MVC Architecture?

> I would:

>  * create a method in your model to fetch the data
>  * create a method in your controller to access this data
>  * create an element that calls via 'requestAction' the data from the controller
>  * insert this element into your layout and add array('cache'=>'1 hour');

take a look at http://bakery.cakephp.org/articles/view/creating-reusable-elements-wi...
for ideas.

jon

--

jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joe  
View profile  
 More options Dec 9 2008, 11:40 am
From: Joe <jBee...@gmail.com>
Date: Tue, 9 Dec 2008 08:40:25 -0800 (PST)
Local: Tues, Dec 9 2008 11:40 am
Subject: Re: Where Does This Fall in the MVC Architecture?
You could also just query the db and assign the value in your
app_controller.php and make it so your layout always checks if that
value is > 0. If it is, display a warning.

On Dec 9, 7:35 am, Tony Thomas <truet...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon Bennett  
View profile  
 More options Dec 9 2008, 11:58 am
From: "Jon Bennett" <jmbenn...@gmail.com>
Date: Tue, 9 Dec 2008 16:58:31 +0000
Local: Tues, Dec 9 2008 11:58 am
Subject: Re: Where Does This Fall in the MVC Architecture?

>  You could also just query the db and assign the value in your
>  app_controller.php and make it so your layout always checks if that
>  value is > 0. If it is, display a warning.

ahh, yes - that's not a very cake way though!

adding 'uses' to your app_controller is a really bad idea, slow things
down no end. And without adding at least one model to uses, you'd need
to load in another model just to get access to make a query. And you
also can't so easily cache the result.

hth

j

--

jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Thomas  
View profile  
 More options Dec 9 2008, 1:58 pm
From: Tony Thomas <truet...@gmail.com>
Date: Tue, 9 Dec 2008 10:58:38 -0800 (PST)
Local: Tues, Dec 9 2008 1:58 pm
Subject: Re: Where Does This Fall in the MVC Architecture?
Fantastic. That worked!

On Dec 9, 9:30 am, "Jon Bennett" <jmbenn...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave C  
View profile  
 More options Dec 9 2008, 7:29 pm
From: Dave C <dmcas...@gmail.com>
Date: Tue, 9 Dec 2008 16:29:45 -0800 (PST)
Local: Tues, Dec 9 2008 7:29 pm
Subject: Re: Where Does This Fall in the MVC Architecture?
Tony,

One approach you could use:

As suggested by Jon Bennett:
* create a method in the model to fetch the data
* create an action in the controller to request the data in the model

Then:
* create a JSON or XML view for the action
* create a JavaScript control for your display that will
asynchronously request and display the data.

Since you want it on every page, you can put the control in your
layout.

I've taken this approach and it works nicely. It may not be an issue
for your case, but it's especially good for queries that aren't really
fast.

Dave.

On Dec 9, 9:35 am, Tony Thomas <truet...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google