raslin Posted October 24, 2010 Share Posted October 24, 2010 hello guys, i'm building mvc framework just for study, any way, i got this dilema, lets say the controller gets data, and i have to validate it, i have 2 classes (in the model folder) validation class send class in the conntroller i can do like that: <? $data = $_POST['data']; $valid = new validate; $data = $valid->validate($data); $send = new send; $send->sendit($data); ?> and the second option is calling the validate class from the send class like that <? class send{ var $valid; var $data function __donstruct($data){ $this->data = $data; $valid = new validate; } public function sendit(){ $this->valid->validate($this->date) return $data; } } ?> its of course not my MVC i just invented somethid for the demonstration of my architecture dilema. hope to get help, thanks alot! Quote Link to comment https://forums.phpfreaks.com/topic/216693-serious-dilema-about-mvc-architecture/ Share on other sites More sharing options...
trq Posted October 24, 2010 Share Posted October 24, 2010 Both send and validate do not sound like Models to me. If that is your question. Quote Link to comment https://forums.phpfreaks.com/topic/216693-serious-dilema-about-mvc-architecture/#findComment-1125822 Share on other sites More sharing options...
ignace Posted October 24, 2010 Share Posted October 24, 2010 Use a framework instead of rolling your own. Send makes no sense and Validate is too general. class SomeController extends Zend_Controller_Action { function someAction() { $form = new SomeForm(); if($this->_request->isPost()) { if($form->isValid()) { $form->process(); } } $this->view->form = $form; } } An example in Zend framework Quote Link to comment https://forums.phpfreaks.com/topic/216693-serious-dilema-about-mvc-architecture/#findComment-1125843 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.