diff --git a/README.md b/README.md index 895bb91..fb37b41 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ [![Codecov Coverage](https://img.shields.io/codecov/c/github/cycle/active-record?style=flat-square&logo=codecov)](https://app.codecov.io/gh/cycle/active-record) [![Type Coverage](https://shepherd.dev/github/cycle/active-record/coverage.svg)](https://shepherd.dev/github/cycle/active-record) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat-square&label=mutation%20score&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fcycle%2Factive-record%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/cycle/active-record/master) +[![MetaStorm plugin](https://img.shields.io/static/v1?label=Meta+Storm&message=annotated&color=008880&style=flat-square&logo=data:image/svg%2bxml;base64,PHN2ZyB3aWR0aD0iMTExIiBoZWlnaHQ9IjExMSIgdmlld0JveD0iMCAwIDExMSAxMTEiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTYwLjQ2MTcgOEwzMC4xNjU0IDguMjQ3OUMyNy4yNDYgOC4yNzE3OSAyNC42NDggMTAuMTA1IDIzLjY0NyAxMi44NDc1TDAuNDMwNTkgNzYuODMxNEMtMS4yNDQ1OSA4MS40MjA4IDIuMTc4MDUgODYuMjcxMyA3LjA2MzUzIDg2LjIzMTNMMzIuMTE5NyA4Ni4wMjYzTDM1LjQxNDcgNzYuOTk5TDkuODczOTEgNzcuMjA4TDMxLjYyNTkgMTcuMjM2Mkw1Ny4xNjY2IDE3LjAyNzNMNjAuNDYxNyA4WiIgZmlsbD0iI0FGQjFCMyIvPjxwYXRoIGQ9Ik00OS40MTQ5IDEwMi45OTlMNzkuNzEyMiAxMDIuOTk5QzgyLjYzMTcgMTAyLjk5OSA4NS4yNDQ2IDEwMS4xODcgODYuMjY4IDk4LjQ1MjlMMTEwLjAxMyAzNC40NTI0QzExMS43MjYgMjkuODc2OCAxMDguMzQzIDI0Ljk5ODUgMTAzLjQ1NyAyNC45OTg1TDc4LjQwMDQgMjQuOTk4NUw3NS4wMzE2IDMzLjk5ODVMMTAwLjU3MyAzMy45OTg1TDc4LjMyNTMgOTMuOTk5TDUyLjc4MzcgOTMuOTk5TDQ5LjQxNDkgMTAyLjk5OVoiIGZpbGw9IiNBRkIxQjMiLz48cGF0aCBkPSJNMjIgNjFMODYgOEw1NyA1MEw4OS45OTk3IDQ5Ljk5OTdMMjYgMTAzTDU1IDYxSDIyWiIgZmlsbD0iI0M3NTQ1MCIvPjwvc3ZnPg==)](https://github.com/xepozz/meta-storm-idea-plugin) + [![Discord](https://img.shields.io/discord/538114875570913290?style=flat-square&logo=discord&labelColor=7289d9&logoColor=white&color=39456d)](https://discord.gg/spiralphp) [![Follow on Twitter (X)](https://img.shields.io/badge/-Follow-black?style=flat-square&logo=X)](https://x.com/intent/follow?screen_name=SpiralPHP) @@ -154,6 +156,46 @@ $user = User::create(name: 'John'); $user->saveOrFail(); ``` +### → Advanced Usage Examples + +#### Query Builder Integration + +```php +// Find users with advanced Cycle ORM filtering +$user = User::query() + ->where('name', 'John') + ->where('active', true) + ->fetchOne(); + +// Find by primary key +$user = User::findByPK(42); + +// Find with conditions +$users = User::findAll(['status' => 'active']); +$user = User::findOne(['email' => 'john@example.com']); +``` + +#### Batch Operations and Transactions + +```php +$user1 = new User('Alice'); +$user2 = new User('Bob'); + +// Group multiple operations in a single transaction +ActiveRecord::groupActions(function (EntityManagerInterface $em) use ($user1, $user2) { + $user1->save(); + $user2->save(); + // Both users saved in one transaction +}, TransactionMode::OpenNew); + +// Advanced transaction handling +User::transact(function (DatabaseInterface $db, EntityManagerInterface $em) { + $user = User::query()->forUpdate()->fetchOne(['name' => 'Charlie']); + $user->name = 'Charles'; + $user->save(); +}); +``` +
## 🙌 Want to Contribute? diff --git a/resources/ar.meta-storm.xml b/resources/ar.meta-storm.xml new file mode 100644 index 0000000..c4dfe53 --- /dev/null +++ b/resources/ar.meta-storm.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +