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(); 
Sign up to request clarification or add additional context in comments.

1 Comment

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.
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 Comment

Thanks. I don't know for sure. I just wanted to know how to call another PHP page and send the information to it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.