Jump to content

creating a single model for multiple tables


son.of.the.morning

Recommended Posts

I am using cakephp to create a cms as i have properly said in numerous posts lol. I am totally new to MVC so it's quite a head fuck at the moment. I have followed a tutorial on how to create a blog using cakephp and from what i have so far i understand how to create a model for one table. In my cms i have multiple tables when i want to be able to interact with on a single page. I really don't no were to start with it at all so if anyone can give me a little help or a push in the right direction it would be much appreciated.

 

Thanks 

Link to comment
Share on other sites

Create a model for each table. This makes sure that you can benefit of all what the framework has to offer (Like the Associations in CakePHP). Create a new model that will sit on top of these table models.

 

class FridgeController extends AppController {
    public function analyseMyFridgeAndReturnPossibleRecipes() {
        $recipes = $this->FridgeRepository->findPossibleRecipesByFridgeContents();
        return $recipes;
    }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.