Assigning Object to View, big MySQL resultset.
Posted
by A Finn
on Stack Overflow
See other posts from Stack Overflow
or by A Finn
Published on 2010-04-15T10:24:37Z
Indexed on
2010/04/15
10:43 UTC
Read the original article
Hit count: 192
Hello (Sorry for my bad English)
Is it bad practice to assign object to view and call its methods in there? I use smarty as my template engine.
In my controller I could do like this
1#
$this->view->assign("name", $this->model->getName);
and in my view
<p>{$name}</p>
OR
2#
$this->view->assign("Object", $this->model);
and in my view
<p>{$Report->getName()}</p>
Well my biggest problem is that I have to handle a big amount of data coming out from the MySQL and I thought that if I would made a method that would print out the data while looping mysql_fetch_row. Well at least I know that using html-tags in the model is a bad thing to do.
So I would assign the object to the view to get the result to the right position on the page..
Reading a mysql-result to an array first may cause memory problems am I right? So what is the solution doing things MVC style..
And yes Im using a framework of my own.
© Stack Overflow or respective owner