The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

How to call a model function?

devyn's Avatar


05 Apr, 2012 09:16 AM

I'm using Paris & Idiorm for ORM interface.
So I've created models folder and have model classes.
Problem is I don't know how to call the functions from those models because I want to move all business logic to model files.
My main working files is index.php.

  1. Support Staff 1 Posted by Josh Lockhart on 05 Apr, 2012 11:43 AM

    Josh Lockhart's Avatar

    Your Paris models extend base class Model. You can then add whatever methods necessary to the subclass and invoke those as necessary in your Slim application. To create a model:

    //New instance
    $carInstance = Model::factory('Car')->create();
    //Find by ID
    $carInstance = Model::factory('Car')->find_one($id);
    //Find all by where clause
    $carInstances = Model::factory('Car')->where('color', 'red')->find_many();

    There's much more you can do. You should read the Idiorm ORM documentation to see all methods available to you. If you have any more questions specific to Paris or Idiorm, you may be better off asking them on the repos themselves:

    Hope this helps!

  2. 2 Posted by ait.meijin on 09 Apr, 2012 08:29 AM

    ait.meijin's Avatar

    This tutorial nicely describes Slim+Idiorm+Paris combo:

  3. Andrew Smith closed this discussion on 01 Aug, 2012 12:53 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac