Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
[ORM] How to use view tables
  • Is it possible to use table views in ORM? I tried it by using $_table_name but it doesn't work. 
  • Yes, you can.

    You define your views in the model:

    protected $_views = array(
        'viewname' => array(
            'columnA',
            'columnB',
            'columnC',
        ),
    );

    Then in the query you use

    Model_This::query()->use_view('viewname')-> ...

    or

    Model_This::find('all', array('use_view' => 'viewname));

  • HarroHarro
    Accepted Answer
    Note that you can only SELECT from a view, INSERT/UPDATE are not supported.
  • Does this also accept relationships?

Howdy, Stranger!

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

In this Discussion