Instance model

The following model extends on Dbi().

User.php
use Stilmark\Database\Dbi;

class User extends Dbi {

    const table = 'users';

}

Use the model from a controller.

UserController.php
use WebApp\Model\User;

class UserController extends Request {

    function index() {
    	return User::limit(100)->list();
    }

    function show() {
        return User::get( Request::arg('id') );
    }
}

Last updated