PHPackages                             mezon/crud-service-model - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. mezon/crud-service-model

ActiveLibrary

mezon/crud-service-model
========================

Model with CRUD operations

1.2.23(2y ago)28.9k1MITPHPPHP &gt;=7.2.0

Since May 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/alexdodonov/mezon-crud-service-model)[ Packagist](https://packagist.org/packages/mezon/crud-service-model)[ Docs](https://github.com/alexdodonov/mezon-crud-service-model)[ RSS](/packages/mezon-crud-service-model/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (23)Used By (1)

CRUD model
==========

[](#crud-model)

This model will help you to create CRUD models for your entitites, and provides you a huge set of methods after a simpe setup.

Installation
------------

[](#installation)

Just print in console

```
composer require mezon/crud-service-model

```

And that's all )

First steps
-----------

[](#first-steps)

Let's define a new class for your DB entity:

```
class EntityModel extends CrudServiceModel
{
	/**
	 * Constructor
	 */
	public function __construct()
	{
		parent::__construct('*', 'entity_table_name');
	}
}
```

In this exact line of code:

```
parent::__construct('*', 'entity_table_name');
```

We have specified that we need `'*'` (all fields) from the table with name `'entity_table_name'`.

If you need only some fields from your database, just list them in the first parameter:

```
parent::__construct('id,field1,field2,field3', 'entity_table_name');
```

And when you have done this, you will get the following methods.

But before using these methods note that you will need to meet the requirements for some naming conventions.

Field with the primary key must be named as `id`. I shall add setting to use another name.

Some methods reqire field `creation_date` for fetching new records for example.

You may add to the table field `domain_id` for implementing multy instancing out of the box.

Now lets look at available methods:

```
// Method fetches all new records since the $date
// For example $model->newRecordsSince($domainId, '2021-01-01');
newRecordsSince($domainId, string $date): array;
```

```
// Method calculates count of records fetched by filter
// For example $model->recordsCount(false, ['field1 = 1', 'field2 = 2']);
recordsCount($domainId = false, array $where = ['1=1']);
```

```
// Method returns data as is without any transformations
getSimpleRecords($domainId, int $from, int $limit, array $where, array $order = []): array;
```

```
// Method returns records wich are transformed by method getRecordsTransformer wuch
// you can override in your subclass
getRecords($domainId, int $from, int $limit, array $where = ['1=1'], array $order = []): array;
```

```
// Method returns the last $count records filtered by where
lastRecords($domainId, $count, $where): array;
```

```
// Method returns records by their ids
fetchRecordsByIds($domainId, string $ids): array;
```

```
// Method calculates count of records grouped by fieldName and filtered by where
recordsCountByField($domainId, string $fieldName, array $where): array;
```

```
// Method updates records with values record
updateBasicFields($domainId, array $record, array $where): array;
```

```
// Method inserts record record
insertBasicFields(array $record, $domainId = 0): array;
```

```
// Method deletes all records filtered by where
deleteFiltered($domainId, array $where): int;
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~56 days

Recently: every ~160 days

Total

22

Last Release

994d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/14943896?v=4)[alexdodonov](/maintainers/alexdodonov)[@alexdodonov](https://github.com/alexdodonov)

---

Top Contributors

[![alexdodonov](https://avatars.githubusercontent.com/u/14943896?v=4)](https://github.com/alexdodonov "alexdodonov (39 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mezon-crud-service-model/health.svg)

```
[![Health](https://phpackages.com/badges/mezon-crud-service-model/health.svg)](https://phpackages.com/packages/mezon-crud-service-model)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
