# Same table can be used multiple times to define different types of associations

**URL:** <https://discourse.cakephp.org/t/same-table-can-be-used-multiple-times-to-define-different-types-of-associations/9669>\
**Category:** Need Help\
**Created:** [August 30, 2021, 7:22pm UTC](https://discourse.cakephp.org/t/same-table-can-be-used-multiple-times-to-define-different-types-of-associations/9669 "2021-08-30T19:22:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Herzberg](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@Herzberg](https://discourse.cakephp.org/u/Herzberg)\
**Post date:** [August 30, 2021, 7:22pm UTC](https://discourse.cakephp.org/t/same-table-can-be-used-multiple-times-to-define-different-types-of-associations/9669/1 "2021-08-30T19:22:27Z")

</div>

How can I use this snippet of the Book (Associations - Linking Tables Together) :

class ArticlesTable extends Table  
{  
public function initialize(array $config): void  
{  
$this-\>hasMany(‘Comments’)  
-\>setFinder(‘approved’);

```
    $this->hasMany('UnapprovedComments', [
            'className' => 'Comments'
        ])
        ->setFinder('unapproved')
        ->setProperty('unapproved_comments');
}

```

}

After adding a column ‘approved’ (type boolean) to the comments table I get:

Unknown finder method “approved” on App\Model\Table\CommentsTable.

Do they want 2 columns approved and unapproved?

CommentsTable:

public function initialize(array $config): void  
{  
parent::initialize($config);

```
    $this->setTable('comments');
    $this->setDisplayField('id');
    $this->setPrimaryKey('id');

    $this->addBehavior('Timestamp');

    $this->belongsTo('Users', [
        'foreignKey' => 'user_id',
        'joinType' => 'INNER',
    ]);
    $this->belongsTo('Articles', [
        'foreignKey' => 'article_id',
        'joinType' => 'INNER',
    ]);
}
```

---

<div class="post-metadata">

**Author:** ![raul338](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/raul338/32/69_2.png) [@raul338](https://discourse.cakephp.org/u/raul338)\
**Post date:** [August 30, 2021, 11:58pm UTC](https://discourse.cakephp.org/t/same-table-can-be-used-multiple-times-to-define-different-types-of-associations/9669/2 "2021-08-30T23:58:50Z")

</div>

> [@Herzberg](#):
>
> Unknown finder method “approved” on App\Model\Table\CommentsTable.
> 
> Do they want 2 columns approved and unapproved?

If you are naming a finder in the association, you have to [define that finder](https://book.cakephp.org/4/en/orm/retrieving-data-and-resultsets.html#custom-finder-methods)

In your example you have to add `findApproved` and `findUnapproved` to CommentsTable
