0

Using PHP, If I have a model (a class) where I various queries, whatever I need, and in my controller, I use myModel = new CustomerModel(); and later in the controller, say I call myMyodel in the controller (I know looks like codeigniter but I am not using a framework) to:

$data['query'] = myModel.OrderByLastName();

how do I pass that $data['query'] to a view, a separate .php page?

I don't wan to echo anything from my controller.

Also, was hoping this design, the way I explained it makes sense. Or am I wasting time with the model class?

2 Answers 2

2

Typically, you'd instantiate a view object:

$view = new View();

Pass it the info it needs():

$view->set($name1, $value1);
$view->set($name2, $value2);
...

Then invoke the view's renderer:

$view->render();
1
  • Neither, it's just what you might call such a function in your own view layer code. I.e., I'm assuming that you're going to write the View class yourself. Sorry if that wasn't clear. Sep 29, 2010 at 18:49
1

The way Django works is the controller basically renders a template using a templating system. It passes the data in Contexts, like this:

data['query'] = myModel.OrderByLastName();

context = {'data': data['query']}

page = loader.get_template('folder/template.phtml')

return render_to_page(page, context)

roughly.

Obviously, you're writing your own system so you've got some room on exactly how you implement it. I don't know if that's exactly what you want, but it might give you a workable idea.

1
  • Thanks. I don't know for sure. I just wanted to know how to call another PHP page and send the information to it.
    – johnny
    Sep 29, 2010 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.