I am new to MVC. You have been warned ...
I have a User model that can return the MySQL result resource to the controller. The controller passes the MySQL resource to the displayed view. Is it acceptable to print query results in a view using the database results fetch function?
<?php while($row = some_fetching_function($database_result_resource): ?> <tr> <td><?=$row['Username']?></td> ...etc </tr> <?php endwhile; ?>
This does not look right to me. This is closely related, right? A model must return some type of database resource, and a view must pass through it using a data type method of a certain type. Can it be unleashed without repeating the results twice? I think you will have to iterate over the results in the model to create an array of results, and then again in the view.
In short:
- Can a view display a database result resource by adhering to the MVC design pattern?
- Can data cycling be avoided twice by avoiding hard-linking to the database?
Bond - James Bond
source share