Skip to content

Interface for PHP-Applications to access Object-Relational data.

License

Notifications You must be signed in to change notification settings

sweiguny/PHP-Persistence-API

Repository files navigation

PHP Persistence API

Build Status

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:

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
                )
        )
)

About

Interface for PHP-Applications to access Object-Relational data.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages