sweiguny / php-persistence-api
Interface for PHP-Applications to access Object-Relational data.
dev-master
2021-03-18 07:56 UTC
Requires
- php: >=7.2.0
- symfony/cache: ^4.0
- symfony/dependency-injection: ^4
- symfony/event-dispatcher: ^4
- symfony/finder: ^4.0
Requires (Dev)
- mockery/mockery: ^1.2
- phpunit/phpunit: ^8
This package is auto-updated.
Last update: 2024-04-18 14:31:42 UTC
README
The PHP Persistence API (PPA
) is an Interface for PHP-Applications to access Object-Relational data.
Note: this project currently underlies a huge refactoring process.
Features:
- Easy to embed in your project
- Configure entities via annotations
- Relations
- OneToOne
- OneToMany
- ManyToMany
- Relations
- TypedQueries and PreparedQueries.
- CRUD
- Transactions
- Eager & Lazy Loading
- A neat WIKI
Features in spe:
- Inheritance
Examples:
Configuring your entities:
namespace PPA\examples\entity; use PPA\core\Entity; /** * @table(name="role") */ class Role extends Entity { /** * @id * @column(name="id") */ private $id; /** @column(name="name") */ private $name; /** * @manyToMany(fetch = "eager", mappedBy = "_PPA_examples_entity_Right") * @joinTable(name = "role2right", column = "role_id", x_column = "right_id") */ private $rights = array(); }
Retrieving data:
A TypedQuery can automatically resolve all the relations and give an appropriate output.
$query = new \PPA\core\query\TypedQuery("SELECT * FROM `role` WHERE id = 1", "\\PPA\\examples\\entity\\Role"); $query->getSingleResult(); Returns: PPA\examples\entity\Role Object ( [id:PPA\examples\entity\Role:private] => 1 [name:PPA\examples\entity\Role:private] => admin [rights:PPA\examples\entity\Role:private] => Array ( [0] => PPA\examples\entity\Right Object ( [id:PPA\examples\entity\Right:private] => 3 [desc:PPA\examples\entity\Right:private] => ch-pw ) [1] => PPA\examples\entity\Right Object ( [id:PPA\examples\entity\Right:private] => 1 [desc:PPA\examples\entity\Right:private] => login ) ) )