# Xpdo3 | Instantiated a derived class MiApi\\Model\\MiChecklistItems that is not a subclass of

**URL:** <https://community.modx.com/t/xpdo3-instantiated-a-derived-class-miapi-model-michecklistitems-that-is-not-a-subclass-of/6592>\
**Category:** Development\
**Created:** [March 31, 2023, 9:47am UTC](https://community.modx.com/t/xpdo3-instantiated-a-derived-class-miapi-model-michecklistitems-that-is-not-a-subclass-of/6592 "2023-03-31T09:47:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dimmy](https://community.modx.com/user_avatar/community.modx.com/dimmy/32/56_2.png) [@dimmy](https://community.modx.com/u/dimmy)\
**Post date:** [March 31, 2023, 9:47am UTC](https://community.modx.com/t/xpdo3-instantiated-a-derived-class-miapi-model-michecklistitems-that-is-not-a-subclass-of/6592/1 "2023-03-31T09:47:18Z")

</div>

I have a model and this is a part of it, that gives me this error:

```auto
[2023-03-31 10:24:37] (ERROR @/vendor/xpdo/xpdo/src/xPDO/Om/xPDOObject.php : 359) Instantiated a derived class MiApi\Model\MiChecklistItems that is not a subclass of the requested class MiApi\Model\MiChecklistValues

```

This is that part:

```auto
    <object class="MiChecklistItems" table="mi_checklist_items" extends="xPDO\Om\xPDOObject">
        <field key="ID" dbtype="int" precision="20" phptype="integer" null="false" index="pk" generated="native"/>
        <field key="title" dbtype="varchar" precision="255" phptype="string" null="false"/>
        <field key="description" dbtype="varchar" precision="255" phptype="string" null="false"/>
        <field key="field_type" dbtype="varchar" precision="20" phptype="string" null="false"/>
        <field key="field_name" dbtype="varchar" precision="20" phptype="string" null="false"/>
        <field key="field_value" dbtype="text" phptype="string" null="true"/>
        <field key="method" dbtype="text" phptype="string" null="true"/>
        <field key="parent" dbtype="int" precision="20" phptype="integer" default="0"/>
        <field key="method_parent" dbtype="int" precision="20" phptype="integer" default="0"/>
        <field key="section_id" dbtype="varchar" precision="255" phptype="string"/>
        <field key="sort" dbtype="int" precision="3" phptype="integer" default="0"/>

        <index alias="ID" name="ID" primary="true" unique="true" type="BTREE">
            <column key="ID" length="" collation="A" null="false"/>
        </index>

        <aggregate alias="MiChecklistSection" class="MiApi\Model\MiChecklistSections" local="section_id" foreign="ID" cardinality="one" owner="foreign"/>
        <composite alias="MiChecklistValue" class="MiApi\Model\MiChecklistValues" local="ID" foreign="checkitem_id" cardinality="many" owner="local"/>

    </object>

    <object class="MiChecklistValues" table="mi_checklist_values" extends="xPDO\Om\xPDOObject">
        <field key="ID" dbtype="int" precision="20" phptype="integer" null="false" index="pk" generated="native"/>
        <field key="taskslip_id" dbtype="int" precision="2" phptype="integer" default="0"/>
        <field key="checkitem_id" dbtype="int" precision="2" phptype="integer" default="0"/>
        <field key="value" dbtype="text" phptype="string" null="false"/>
        <field key="parent" dbtype="int" precision="20" phptype="integer" default="0"/>
        <field key="user_id" dbtype="int" precision="20" phptype="integer" null="false" default="0"/>
        <field key="date" dbtype="datetime" phptype="datetime" null="false"/>

        <index alias="ID" name="ID" primary="true" unique="true" type="BTREE">
            <column key="ID" length="" collation="A" null="false"/>
        </index>

        <aggregate alias="MiTaskSlip" class="MiApi\Model\MiTaskSlips" local="taskslip_id" foreign="ID" cardinality="one" owner="foreign"/>
        <aggregate alias="MiChecklistItem" class="MiApi\Model\MiChecklistItems" local="checkitem_id" foreign="ID" cardinality="one" owner="foreign"/>

    </object>

```

What could be the problem? I think that the model is ok, but maybe i made a mistake? ore used a reserved column name?

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [March 31, 2023, 9:52am UTC](https://community.modx.com/t/xpdo3-instantiated-a-derived-class-miapi-model-michecklistitems-that-is-not-a-subclass-of/6592/2 "2023-03-31T09:52:05Z")

</div>

> [@dimmy](#):
>
> that gives me this error:

When exactly do you get this error? While parsing the schema or when you try to use your custom classes?

---

<div class="post-metadata">

**Author:** ![dimmy](https://community.modx.com/user_avatar/community.modx.com/dimmy/32/56_2.png) [@dimmy](https://community.modx.com/u/dimmy)\
**Post date:** [March 31, 2023, 10:18am UTC](https://community.modx.com/t/xpdo3-instantiated-a-derived-class-miapi-model-michecklistitems-that-is-not-a-subclass-of/6592/3 "2023-03-31T10:18:21Z")

</div>

When i use them in my classes.

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [March 31, 2023, 10:24am UTC](https://community.modx.com/t/xpdo3-instantiated-a-derived-class-miapi-model-michecklistitems-that-is-not-a-subclass-of/6592/4 "2023-03-31T10:24:12Z")

</div>

The schema looks ok (at least the part you shared) and when I test it, a simple `getCollection()` call seems to work correctly.

Can you share the code you use?  
Maybe it’s just that you use `$modx->newQuery()` for one class, and then `getObject()/getCollection()` for a different one.

---

<div class="post-metadata">

**Author:** ![dimmy](https://community.modx.com/user_avatar/community.modx.com/dimmy/32/56_2.png) [@dimmy](https://community.modx.com/u/dimmy)\
**Post date:** [March 31, 2023, 10:29am UTC](https://community.modx.com/t/xpdo3-instantiated-a-derived-class-miapi-model-michecklistitems-that-is-not-a-subclass-of/6592/5 "2023-03-31T10:29:34Z")

</div>

```auto
        $c = $this->xpdo->newQuery(MiChecklistItems::class);
        $c->leftJoin(
            MiChecklistValues::class,
            'MiChecklistValues',
            'MiChecklistItems.ID = MiChecklistValues.checkitem_id AND MiChecklistValues.taskslip_id = ' . $taskslip_id
        );
        $c->where([
            'MiChecklistItems.sliptype_id' => $sliptype_id
        ]);
        if (null !== $section_id) {
            $c->where([
                'MiChecklistItems.section_id' => $section_id
            ]);
        }
        $c->select(
            'MiChecklistValues.*,MiChecklistItems.*'
        );

        $checklistItems = $this->xpdo->getCollection(MiChecklistValues::class, $c);

```

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [March 31, 2023, 10:32am UTC](https://community.modx.com/t/xpdo3-instantiated-a-derived-class-miapi-model-michecklistitems-that-is-not-a-subclass-of/6592/6 "2023-03-31T10:32:15Z")

</div>

> [@dimmy](#):
>
> `$this->xpdo->newQuery(MiChecklistItems::class);`

> [@dimmy](#):
>
> `$this->xpdo->getCollection(MiChecklistValues::class, $c);`

I believe you have to use the same class here.  
If it has to be “MiChecklistValues” for the getCollection call, then try using the same class (and a `rightJoin` to “MiChecklistItems”) in the query.

---

<div class="post-metadata">

**Author:** ![dimmy](https://community.modx.com/user_avatar/community.modx.com/dimmy/32/56_2.png) [@dimmy](https://community.modx.com/u/dimmy)\
**Post date:** [March 31, 2023, 10:32am UTC](https://community.modx.com/t/xpdo3-instantiated-a-derived-class-miapi-model-michecklistitems-that-is-not-a-subclass-of/6592/7 "2023-03-31T10:32:49Z")

</div>

I see my error now… indeed the two different classnames…

---

<div class="post-metadata">

**Author:** ![system](https://community.modx.com/user_avatar/community.modx.com/system/32/2_2.png) [@system](https://community.modx.com/u/system)\
**Post date:** [April 2, 2023, 10:33am UTC](https://community.modx.com/t/xpdo3-instantiated-a-derived-class-miapi-model-michecklistitems-that-is-not-a-subclass-of/6592/8 "2023-04-02T10:33:10Z")

</div>

Closed on April 2, 2023, 10:33am UTC

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.
