Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[RFC] DB Abstraction Layer #31

@geggleto

Description

@geggleto

I know we all love different DB ORM layers... I think it would be nice to have some sort of standard so we can easily swap vendors when building our applications.

I think this ties in with the concept of application bundles as well.

I think a good base would simply expose a set of methods for CRUD... This is very similar to a Table Row Gateway.

Example implementation 1

interface CRUDInterface {
    public function getPdo(); /* returns \Pdo */
    public function select($columns = '', $from = '', $where = ''); /* returns array[] */
    public function update(array $properties, $table = '', $where = '');  /* returns int */
    public function delete($table = '', $where = ''); /* returns int */
    public function insert(array $properties, $table = ''); /* returns int */
}

Example implementation 2

interface CRUDInterface {
    public function getPdo(); /* returns \Pdo */
    public function setTable($table = '');
    public function select($columns = '', $where = ''); /* returns array[] */
    public function update(array $properties, $where = '');  /* returns int */
    public function delete($where = ''); /* returns int */
    public function insert(array $properties); /* returns int */
}

What get's tricky is the return types of these and what the method signatures should be.

The Goal

The goal of this would not be to get different DB ORM Vendor's to adopt this interface. We are simply attempting to define a set of methods that we can all use with adapter libraries. I don't think Community bundles can happen without a standardized DB implementation.

Looking forward to your comments!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions