Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/216693-serious-dilema-about-mvc-architecture/
Share on other sites

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.