PHPackages                             taxaos/doctrine-bulk - 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. taxaos/doctrine-bulk

ActiveLibrary[Database &amp; ORM](/categories/database)

taxaos/doctrine-bulk
====================

Simple classes that allows bulk operations on doctrine entities (only mySQL upsert supported)

4.0.1(3y ago)06.6k1[1 PRs](https://github.com/taxaos/doctrine-bulk/pulls)MITPHPPHP &gt;=8.0

Since Dec 28Pushed 1y agoCompare

[ Source](https://github.com/taxaos/doctrine-bulk)[ Packagist](https://packagist.org/packages/taxaos/doctrine-bulk)[ RSS](/packages/taxaos-doctrine-bulk/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (6)Versions (19)Used By (0)

Doctrine-Bulk Classes for MySQL
===============================

[](#doctrine-bulk-classes-for-mysql)

Adds ability to multiple upsert / insert on duplicate (MySQL only) of entities or array to database using doctrine schema and ORM objects.

```
INSERT ... ON DUPLICATE KEY UPDATE Statement for ORM objects
    INSERT INTO t1 (a,b,c) VALUES (1,2,3)
    ON DUPLICATE KEY UPDATE c=c+1;

```

Be warned: this function will just take your list of your ORM objects and will create the insert on duplicate sql query

- Supported Relationship / Join Types are ONE\_TO\_ONE AND MANY\_TO\_ONE
- LifeCycleCallbacks Events::prePersist / Events::preUpdate are supported
- Your ORM objects can be detached from session to avoid the insert/update triggered by ORM.. \*\* I opted to give you flexibility here, use $detach parameter
- Changes will be sent to DB in chunks

If the world would be nice and Doctrine able to do something else then single insert/update queries for MySQL, i would not need to do this.

Save the planet with less energy used for wasted queries :)

### Samples

[](#samples)

#### Default usage

[](#default-usage)

```
