M = Model Interaction with data stored in a database or via a datasource (eg the twitter example)
Dropping assocs on the fly is easier than building them on the fly You set the associations as they would generally be needed between models within your app Your setting you app up to be able to retrive exactly what you require with the least amount of controller and view coding setting up models in the right way (associations, behaviours, validation, custom find methods) means you can use and reuse these models in versatile ways within your app a lean app with fat models; that custom model method really depends on the complexity of the find you are using; if you can then additionally make it serve other purposes elsewhere - eg pass it params to have it return data for different circumstances and what Jeremy says :) and now Ryan has also answered @ryan - the right thing takes some working out A user name (full and secondname -- 2 fields) username to login hasMany published recipe's (table) hasMany favorite recipe's () A recipee will have One title (which is made into a slug) One slug (an auto field) hasMany->ingredients (table) belongs to user Ingredients Name .... - S On 4 February 2011 05:02, andy_the ultimate baker < [email protected]> wrote: > will u please make it short and approachable to ur point, > becouse no one is having to read a long theses of ur query on the > work > so please make it shor and come in pints, so it would be fine to give > u answer > > regards > andy > > On Feb 3, 7:12 pm, Michael Carriere <[email protected]> wrote: > > Hello everyone! > > > > When recently approached to do some web development for a game whose code > base was in dire need of a rewrite, I was determined on finding a stable, > community supported framework to help speed up the process. I appreciate > Cake's file organization, the way layouts are controlled, among other > things, but I seem to be having a difficult time in the way I should be > understanding the "M" in MVC. I've done enough web development in the past > to be familiar with PHP, but more recently I've worked in object-oriented, > compiled languages, as well as a few web tools built with Django. I could > just give up and "do whatever works", but I feel like there's something > powerful to be taken advantage of here, and I hope you guys can help! > > > > How "magical" is the find() function? Should I be able to run one > exhaustive query and get back all the nested data that I need for a View to > spit out? I guess a better question would be: do you find yourself calling > find() on different sets of data, packaging them together yourself > (presumably with the Set class, right?) and then passing that to the view to > be displayed? > > > > I have some data that is loosely related, and while I can manage to get > at all of it in one query, it requires me using Containable, and dropping > 5-6 associations in. That just seems quite inefficient for me. (Maybe it's > not?) > > > > Coming from many OO languages, after you define a class, you instantiate > it as you want to work with an individual object, play with it as you want, > and throw it out. Correct me if I'm wrong, but it seems that MVC's approach > is more geared towards operating on all the data at once? Or at least in the > case of working with a "Model". > > > > This leads to some confusion for me, because the majority of the > instances where I need to access data, it's of a small subset of the data > I'm storing in the DB for my model. My webgame has "Buildings" in it, which > belong to a User's "Village". Sometimes I want to grab information from a > specific Building, and other times I want to grab only the specific > Buildings of a Village. Is it proper to be define a function within the > model that grabs or manipulates data based on this, like > $this->Village->getBuildingsByVillageId()? Better yet, how do you operate on > 'instances' of your data as defined by your model? > > > > I may have some more questions later, but I'll start this thread with > these two (albeit loaded) questions. > > > > Any help is appreciated, thank you! > > > > - Michael > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected]<cake-php%[email protected]>For > more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
