答案 0 :(得分:0)
问题:当您提到“域名”时,您指的是用户模型和电子邮件模型吗?还是设计模式?
此外,最初(但取决于您的应用程序)在用户模型中使用电子邮件数据库逻辑更合乎逻辑(对我而言),因为我不认为您将在不创建用户的情况下添加电子邮件地址。也就是说,电子邮件模型实际上取决于用户模型,并且在用户模型上可能仅,所以可能它们应该组合在一起?
我会这样做:
将所有数据库逻辑放在模型中,我认为这就是你完成它的方式。
创建一个库或类,以放置与用户有关的应用程序的业务逻辑。 (例如,如果您遵循CodeIgniter模型应该只包含数据库逻辑的标准,那么上传图像或连接到Web服务不应该在模型中,这就是为什么我创建另一个类来处理这些情况的原因)
create_user()
class Users extends Controller {
public function create() {
// these could be in the constructor!
$this->load->model('users');
$this->load->library('users_logic');
$this->users_logic->set_model($this->users);
// and/or: $this->users_logic->set_email_model($this->email_model);
if ($this->input->post('name')) {
$this->users_logic->create();
}
}
}
class Users extends Controller {
public function create() {
// these could be in the constructor!
$this->load->model('users');
$this->load->library('users_logic');
$this->users_logic->set_model($this->users);
// and/or: $this->users_logic->set_email_model($this->email_model);
if ($this->input->post('name')) {
$this->users_logic->create();
}
}
}