Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 737409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:43:06+00:00 2026-05-14T07:43:06+00:00

Hello (Sorry for my bad English) Is it bad practice to assign object to

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:43:06+00:00Added an answer on May 14, 2026 at 7:43 am

    Ideally you should use the first approach. Unfortunately we don’t live in an ideal world. If it’s too much of a pain to do that I don’t really see a problem with the second approach.
    Isn’t there a way to compromise though? If you could get the names of the columns from your model as an array, you could loop through them and assign each value to smarty dynamically. That way your view would be simpler and you’d avoid a lot of code in the controller.

    As for taking too much memory… it seems improbable that the amount of data you’d post in one page would take up too much memory. I think you’d be having UI problems (too much stuff in a single page) long before you have memory problems. In any case why don’t you try a simple benchmark. You could use PHP’s memory_get_usage() function for that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first of all sorry by my bad english, Hello i am new in this
Hello and sorry for my bad english! I have a table like this: <table
First of all hello people, and sorry for my bad English, I'm Brazillian! I've
First : Appologize for my bad english. Sorry for this newbie software question, but
Hello i need to know there my flash application is running. in object src
hello there and sorry for the stupid question but i think i might be
first,sorry for my bad English!! i'm new here and i'm a beginner of android
Hello for all people... Sorry for my english, but speak spanish... In this week,
Hello first sorry if its a stupid question, but I amm a beginner, and
Hello First sorry for my english. I have started recently my first project on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.