Passing sql results to views hard-codes views to database column names
Posted
by Galen
on Stack Overflow
See other posts from Stack Overflow
or by Galen
Published on 2010-04-17T05:12:53Z
Indexed on
2010/04/17
5:23 UTC
Read the original article
Hit count: 464
I just realized that i may not be following best practices in regards to the MVC pattern.
My issue is that my views "know" information about my database
Here's my situation in psuedo code...
My controller invokes a method from my model and passes it directly to the view
view.records = tableGateway.getRecords()
view.display()
in my view
each records as record
print record.name
print record.address
...
In my view i have record.name and record.address, info that's hard-coded to my database. Is this bad?
What other ways around it are there other than iterating over everything in the controller and basically rewriting the records collection. And that just seems silly.
Thanks
© Stack Overflow or respective owner