> For the complete documentation index, see [llms.txt](https://xoops.gitbook.io/xoops-modules-cookbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xoops.gitbook.io/xoops-modules-cookbook/core-classes/core/xoopsobjectandhandler.md).

# XoopsObject & XoopsObjectHandler

XOOPS' early data persistence architecture was based on the [Data Mapper pattern](http://martinfowler.com/eaaCatalog/dataMapper.html), with two abstract classes to aid in the class development **XoopsObject** and **XoopsObjectHandler**

* XoopsObject: abstract class of Data Object
* XoopsObjectHandler: Mapper. An abstract class that saves XoopsObject in DB or rebuilds XoopsObject from DB&#x20;

![](/files/-M5b2fILg_qP-PDV4l-9)

The idea behind them is that a class can extend **XoopsObject** to describe an object, whereas extending **XoopsObjectHandler** will give more like an interface for handling the objects, i.e. get, insert, delete and create objects.

E.g. for a `ThisObject` class, you can make a `ThisObjectHandler` to get, insert, delete and create `ThisObject` objects.

The advantages of extending these two classes are for **XoopsObject**:

* Automatic access (inheritance) to methods, easing the assignment/retrieval of variables
* Automatic access to methods for cleaning/sanitizing variables

and for **XoopsObjectHandler**:

* A place to put all those functions working with more than one object i.e. (e.g. a "getAllObjects()" function).

These functions will become easier to track down in the file system (since they are connected to a class, it is just a matter of finding the class and not going through the function files in the module/core/PHP native in search for it.

An additional idea is that the **XoopsObjectHandler**-extending class should be a **Data Access Object**, i.e. the class, which handles database calls - and leaving the **XoopsObject**-extending class to have object-describing methods, such as methods which handle and manipulate variables, calling methods on the handler for retrieving, updating and inserting data in the database.

In XOOPS 2.3 we've added a new enhanced version of the **XoopsObjectHandler**, the **XoopsPersistableObjectHandler**, that incorporated features/characteristics from the [**Repository Pattern**](https://martinfowler.com/eaaCatalog/repository.html)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://xoops.gitbook.io/xoops-modules-cookbook/core-classes/core/xoopsobjectandhandler.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
