Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Correct utilization of db calls within controllers.
  • Now, I know that all database queries are meant to reside within models, and not controllers. So that leads my curiosity to the following: What about when utilizing ORM? Is it considered correctly to use things like $result = DB::select('id','name')->from('users')->execute();
    or
    $result = Model_users::find('all'); At the top of your controller when displaying a users page? Or what is the correct way of using this within a model? You're not writing a query, but utilizing an object that can already be considered a model, such as the ORM method. So should I be declaring a method to select all of the user accounts, or is utilizing the ORMs functionality from the controller okay to do?
  • I use Viewmodels for "list" type screens. My controller takes care of the specifics (like which page, which columns, how many rows, etc), the Viewmodel does the rest. See http://fuelphp.com/docs/general/viewmodels.html.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion