# Fetching a model in 5.x

**URL:** https://discourse.cakephp.org/t/fetching-a-model-in-5-x/12792
**Category:** Uncategorized
**Created:** [January 21, 2026, 9:05pm UTC](https://discourse.cakephp.org/t/fetching-a-model-in-5-x/12792 "2026-01-21T21:05:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![u0398](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/u0398/32/3312_2.png) [@u0398](https://discourse.cakephp.org/u/u0398)
#### Post date: [January 21, 2026, 9:05pm UTC](https://discourse.cakephp.org/t/fetching-a-model-in-5-x/12792/1 "2026-01-21T21:05:07Z")

</div>

I’ve been struggling to use fetchModel() in a class. According to the information in the [Book](https://book.cakephp.org/5/en/controllers.html#loading-additional-tables-models) this should work:

```auto
use ModelAwareTrait;
...
class AuthorsController extends AppController
{
    public function view($slug)
    {
        $articles = $this->fetchModel('Articles');
...

```

But I get an undefined method error:

> Call to undefined method App\Controller\AuthorsController::fetchModel()

What am I missing?

---

<div class="post-metadata">

### Author: ![dereuromark](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dereuromark/32/37_2.png) [@dereuromark](https://discourse.cakephp.org/u/dereuromark)
#### Post date: [January 22, 2026, 4:12am UTC](https://discourse.cakephp.org/t/fetching-a-model-in-5-x/12792/2 "2026-01-22T04:12:58Z")

</div>

Why are you not using the directly above documented fetchTable()?

Maybe you are not fully/properly including the trait, as with the trait both should be available.  
fetchTable() is the primary recommended method for loading ORM tables

- fetchModel() requires you to explicitly add ModelAwareTrait to your  
controller first, and is intended for loading non-ORM models (Elastic,  
Webservice, etc.)

---

<div class="post-metadata">

### Author: ![u0398](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/u0398/32/3312_2.png) [@u0398](https://discourse.cakephp.org/u/u0398)
#### Post date: [January 22, 2026, 4:35am UTC](https://discourse.cakephp.org/t/fetching-a-model-in-5-x/12792/3 "2026-01-22T04:35:11Z")

</div>

I would like to paginate the results. I may have misunderstood the docs, and thought that I needed a model to do that. After trying with fetchTable(), lit looks like paginate is generating a result set.

I do have a question while I’ve got you though. I have an author’s table with an associated articles table. On an author page I want to paginate the author’s associated articles. The controller function looks like this:

```auto
public function view($slug)
{
   $author = $this->Authors->findBySlug($slug)->contain('Articles.Tags')->firstOrFail();

    $this->set(compact('author'));
}

```

Is it possible to paginate contained tables, or is a separate table request necessary?

---

<div class="post-metadata">

### Author: ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)
#### Post date: [January 22, 2026, 8:13am UTC](https://discourse.cakephp.org/t/fetching-a-model-in-5-x/12792/4 "2026-01-22T08:13:41Z")

</div>

> [@u0398](#):
>
> Is it possible to paginate contained tables, or is a separate table request necessary?

There is no CakePHP builtin method to paginate over associated records as the eager loader always loads all associated records.

If you want to display associated records in a paginated matter you will have to create a separate query instance and filter accordingly.
