我使用 Codeigniter 已经有一段时间了,我希望拥有处理逻辑的业务对象,如下所示:
$comment = new Comment($this->input->post());
$blog = new Blog();
$current_post = $blog->get_current_post();
$current_post->add_comment($comment);
$data['current_post'] = $current_post;
$this->load->view('post_view',$data);
而不是这种方法:
$this->load->model('comment_model');
$this->load->model('blog_model');
$this->load->model('post_model');
$comment = $this->comment_model->create_from_array($this->input->post());
$blog = $this->blog_model->get_blog();
$current_post = $this->post_model->get_current_post($blog);
$this->post_model->add_comment($current_post,$comment);
$data['current_post'] = $current_post;
$this->load->view('post_view',$data);