开发者

CakePHP, how it should be used to create this(inside) app?

开发者 https://www.devze.com 2023-02-13 06:17 出处:网络
What I have is the following db structure(tables): lists[name,id] list_items[title,list_id,content] I\'ve created the needed files and code(the MVC) needed to manage the first table(lists).

What I have is the following db structure(tables):

lists[name,id]

list_items[title,list_id,content]

I've created the needed files and code(the MVC) needed to manage the first table(lists).

I also added the hasMany to the model class. At that point I am stuck.

What I need is a solution for managing each item (basic CRUD, I assume that complex management is just an advanced CRUD that I will find out how to do by myself).

I will be specific: since it's a content that have no place (but the admin) that it will be used by itself, should I -

  1. create a full mvc structure for it? (can or should I implement it somehow[how?] in the lists package?
  2. if not, how can I attach the tables? (since the use is about to be dropped in version 2)
  3. would an element(cake concept/context开发者_如何学C) will be the appropriate way to create a view for such situation?

ANY insight will be appreciated.


If I undertant correctly, you want to create a CRUD part of this tables by yourself, without bake.

You need to write all the MVC estrucure and be carefull with the naming combention of cakephp http://cakebaker.42dh.com/2006/02/18/cakephp-conventions/

You need the model into app/models and also a a controller into app/controllers (remember naming combentions) and for each model you need a folder into /app/views.

Alfo, every, every function in your controller needs a view, even if this action doesn´t write anything to screen

I hope this was usefull.


Have you tried using Cake's bake feature? Your CRUD will be automatically created in about 2 seconds. I would also recommend you do the Blog tutorial to get a feel for scaffolding.

CakePHP is all about convention over configuration. Eg naming conventions for tables, controllers, models etc.. So much can be done automagically.

0

精彩评论

暂无评论...
验证码 换一张
取 消