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 <[EMAIL PROTECTED]> wrote: > 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? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Where Does This Fall in the MVC Architecture?
Fantastic. That worked! On Dec 9, 9:30 am, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > > 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 > athttp://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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
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 <[EMAIL PROTECTED]> wrote: > 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? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
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-with-requestaction for ideas. jon -- jon bennett w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Where Does This Fall in the MVC Architecture?
Hi Tony, > 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. 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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
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? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---