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

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

c24-toys/doctrine-bulk
======================

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

4.0.2(3y ago)0992MITPHPPHP &gt;=8.0

Since Jan 24Pushed 3y ago2 watchersCompare

[ Source](https://github.com/C24-Toys/doctrine-bulk)[ Packagist](https://packagist.org/packages/c24-toys/doctrine-bulk)[ RSS](/packages/c24-toys-doctrine-bulk/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (6)Versions (3)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)

```
