https://github.com/roydejong/php-activerecord-utils
Simple utilities that make writing php-activerecord queries more convenient.
https://github.com/roydejong/php-activerecord-utils
Last synced: 10 months ago
JSON representation
Simple utilities that make writing php-activerecord queries more convenient.
- Host: GitHub
- URL: https://github.com/roydejong/php-activerecord-utils
- Owner: roydejong
- License: mit
- Created: 2019-08-28T14:19:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-28T17:12:47.000Z (almost 7 years ago)
- Last Synced: 2025-08-02T22:31:03.133Z (11 months ago)
- Language: PHP
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ✍ `php-activerecord-utils`
**Simple utilities that make writing `php-activerecord` queries more convenient.**
[](https://packagist.org/packages/roydejong/php-activerecord-utils)
[](https://travis-ci.org/roydejong/php-activerecord-utils)
[](https://packagist.org/packages/roydejong/php-activerecord-utils)
## Getting started
Add this library as a [Composer](https://getcomposer.org/) dependency:
composer require roydejong/php-activerecord-utils
Once included, you'll be able to autoload the desired classes from the `ActiveRecordUtils\` namespace.
## Conditions
`ActiveRecordUtils\Composers\Conditions` lets you elegantly compose readable `conditions` parameters for activerecord queries.
### Basic usage
```
where('employee_id = ?', 123)
->or('login_id = ?', 123)
->andWhere('is_enabled = 1')
->value();
// Returns: ["(employee_id = ? OR login_id = ?) AND (is_enabled = 1)", 123, 123]
```
### Features
- 📝 **Better syntax:** Programmatically compose your WHERE clauses with a syntax that's easier to read and more convenient to maintain.
- ➕ **Easy grouping:** Use `andWhere()`, `orWhere()` to start a new parentheses group, or use `and()`, `or()` to add another condition to he current group.
- ✅ **Auto validation:** Issues like wrong parameter count are automatically detected and produce convenient and readable error messages.