dhrrgn / abstract-data-layer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Abstract Data Layer

This is an example of a nice way to abstract your data layer. The example is using Aura\Sql (and so should you).

You will notice the Model never touches the database...that is the Repositories' job.

Example Usage

<?php

require 'vendor/autoload.php';

$connectionFactory = new Aura\Sql\ConnectionFactory;
$connection = $connectionFactory->newInstance('mysql', [
	'host' => 'localhost',
	'port' => '3306',
	'dbname' => 'foo',
], 'foo', 'bar');

$users = new Example\User\UserRepository($connection);
var_dump($users->getById(1));

About


Languages

Language:PHP 100.0%