PHPackages                             mrssoft/yii2-db - 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. [Database &amp; ORM](/categories/database)
4. /
5. mrssoft/yii2-db

ActiveYii2-extension[Database &amp; ORM](/categories/database)

mrssoft/yii2-db
===============

Yii2 database tools

01851PHP

Since Dec 18Pushed 6y ago2 watchersCompare

[ Source](https://github.com/mrs2000/yii2-db)[ Packagist](https://packagist.org/packages/mrssoft/yii2-db)[ RSS](/packages/mrssoft-yii2-db/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

yii2-db
=======

[](#yii2-db)

Batch insert into database.

[![PHP](https://camo.githubusercontent.com/f299041a5873af6affad396f7e502656de29c9ebe44eb32af71a9a4c30b365cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d7273736f66742f796969322d64622e737667)](https://camo.githubusercontent.com/f299041a5873af6affad396f7e502656de29c9ebe44eb32af71a9a4c30b365cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d7273736f66742f796969322d64622e737667)[![Github](https://camo.githubusercontent.com/2c7bceeeaba06eb806253b3738a35f453bf97bee8d09408bc1c5fa269d34e28c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d7273323030302f796969322d64622e737667)](https://camo.githubusercontent.com/2c7bceeeaba06eb806253b3738a35f453bf97bee8d09408bc1c5fa269d34e28c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d7273323030302f796969322d64622e737667)[![Total Downloads](https://camo.githubusercontent.com/521829aaa29e3b9a04623126c79809bb4514208e207a8fb05dc56cfbc416d554/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7273736f66742f796969322d64622e737667)](https://camo.githubusercontent.com/521829aaa29e3b9a04623126c79809bb4514208e207a8fb05dc56cfbc416d554/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7273736f66742f796969322d64622e737667)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist mrssoft/yii2-db "*"

```

or add

```
"mrssoft/yii2-db": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

```
$batch = new DbBatch();

$batch->add([
    'field1' => $value1,
    'field2' => $value2,
]);

$batch->add([
    'field1' => $value1,
    'field2' => $value2,
], $key)

$batch->addUnique([
    'field1' => $value1,
    'field2' => $value2,
]);

$bool = $batch->insert('{{%table}}', true);
$bool = $batch->replace('{{%table}}');
```

```
$batch = new DbBatch([
    'maxItemsInQuery' => 1000,
    'table' => '{{%table}}',
    'truncate' => true,
    'command' => DbBatch::COMMAND_INSERT
]);

$batch->add([
    'field1' => $value1,
    'field2' => $value2,
], $key);

$batch->update([
    'field1' => $value3,
    'field2' => $value4,
], $key);

$count = $batch->getCount();
$keys = $batch->getKeys();
$element = $batch->get($key);
$data = $batch->getData();
$batch->setData($data);

$bool = $batch->execute();
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e69f6780ee8c8e5b2c10af66e1232ac3925766c6f2f83db1820f2ff9a590a62?d=identicon)[mrs2000](/maintainers/mrs2000)

---

Top Contributors

[![mrs2000](https://avatars.githubusercontent.com/u/2921111?v=4)](https://github.com/mrs2000 "mrs2000 (1 commits)")

### Embed Badge

![Health badge](/badges/mrssoft-yii2-db/health.svg)

```
[![Health](https://phpackages.com/badges/mrssoft-yii2-db/health.svg)](https://phpackages.com/packages/mrssoft-yii2-db)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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