English 中文(简体)
MVC:模型、主计长还是图书馆?
原标题:MVC: Model, Controller or Library?

我首次使用一个框架(代码员)来建立客户关系管理程序,而且我很难确定某个模块在维持监查方法的同时应该到哪里去。 该模块自动生成一个新的用户( 当新公司创建时), 并将日志细节发送到提供的电子邮件地址 。

我熟悉瘦密控制器和脂肪模型的概念,但为了汇编所有所需的信息,模块必须要求从几个不同的表格中获取数据,并将数据插入几个表格中。

迄今为止,我所考虑的假设情况如下:

  1. The logic is in the model where most of the information comes from.
  2. Create a totally new model that deals with just this module and the multiple tables required.
  3. Place the logic in the controller that deals with creating a company.
  4. Create a new library or helper and call the module when it is needed.

Skinny控制器和脂肪模型似乎表明,一两个选项是正确的,但我认为,模型只应处理数据库中的一个表格。

什么是确保遵守监查会的正确办法?

最佳回答

协调者允许你灵活地使用MVC方法。 所以答案是:

  • Easiest for you (or your team) to understand
  • Easiest to code maintain
  • Easiest for someone else to understand

将您的代码输入图书馆是没有道理的, 如果您没有其它图书馆, 并且不理解图书馆。 和您所有的模型都是“ 脂肪 ” 一样, 但只指向一个表格, 您是否希望这个模型是唯一同时指向另外四个表格的模型?

就我个人而言,如果这个"逻辑"只发生在一个地方, 那么我会把它放到控制器里, 然后打电话给4x模型, 你需要做每一个部分的代码。

如果这个“逻辑”发生在多个地方, 我会把它放在图书馆里, 必要时打电话给它。

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签