https://github.com/jitesoft/wp-dbal
Small project intended to create a database abstraction layer between WordPress database and logic. (Mirror)
https://github.com/jitesoft/wp-dbal
dbal php php72 wordpress wp
Last synced: about 2 months ago
JSON representation
Small project intended to create a database abstraction layer between WordPress database and logic. (Mirror)
- Host: GitHub
- URL: https://github.com/jitesoft/wp-dbal
- Owner: jitesoft
- License: mit
- Created: 2018-06-21T06:30:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-25T09:03:30.000Z (almost 8 years ago)
- Last Synced: 2025-08-26T17:26:44.497Z (10 months ago)
- Topics: dbal, php, php72, wordpress, wp
- Language: PHP
- Homepage: https://gitlab.com/jitesoft/open-source/php/wp-dbal
- Size: 94.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# WP-DB Abstraction
**Observe** This project is currently in development and have no release yet. It is not usable in the way that it is intended to
be used when ready.
Feel free to contribute or wait for a v1.0.0 release.
This project is intended to be used as a layer between the database and the logic of the webpage or application created using WordPress.
The intention is that all the base database entities should be represented by models, models which can be acquired via repositories, instead of direct queries.
The base classes in the project will allow for usage of the WordPress database classes or direct PDO access to both show how simple it can be implemented through the repository pattern
and to let you start your project without having to create it all yourself.
As some might notice, the model/entity classes are quite similar to how the `Doctrine` ORM/DBAL works. It uses the same type of annotations
as you would with doctrine if using the annotations to declare the fields and tables.
This is very much intentional, I even use the Doctrine annotation package for the annotations themselves.
The reason to this is to introduce the concept of Doctrine, a ORM/DBAL that I love, to others, making it easier for them to move
over to a framework in which the `Model View Controller` or similar pattern is used.
I intend to implement other mapping types similar to the other doctrine mappings, such as YML based and class based, but that is in
future releases.
## Models
The models, or entities, are classes which represents a single database entry.
A model extends the `AbstractModel` class, which gives it a few methods and traits that enables it to integrate with the
projects underlying classes.
Further more, to allow the model to be able to interact correctly with the database a few annotations are available to use:
* `Model`
* `Field`
### Model annotation
The `Model` annotation is required on a model class, it marks the class as a entity and exposes the database table used by the model through a annotation variable:
```php