2017 © Pedro Peláez
 

library sqlmapper-bundle

A SQL DataMapper implementation.

image

aura/sqlmapper-bundle

A SQL DataMapper implementation.

  • Tuesday, March 8, 2016
  • by pmjones
  • Repository
  • 10 Watchers
  • 14 Stars
  • 4,996 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 4 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Aura.SqlMapper_Bundle

DEPRECATED

This package is DEPRECATED and will not be released in a stable version. Please consider using Atlas instead., (*1)

Foreword

Installation

This bundle is installable and autoloadable via Composer as aura/sqlmapper-bundle., (*2)

Quality

Scrutinizer Code Quality Code Coverage Build Status, (*3)

To run the unit tests at the command line, issue composer install and then phpunit at the package root. This requires Composer to be available as composer, and PHPUnit to be available as phpunit., (*4)

This library attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request., (*5)

Community

To ask questions, provide feedback, or otherwise communicate with the Aura community, please join our Google Group, follow @auraphp on Twitter, or chat with us on #auraphp on Freenode., (*6)

Getting Started

Entity and Factory

 $value) {
            $this->$field = $value;
        }
    }
}

class PostFactory extends ObjectFactory
{
    public function newObject(array $row = array())
    {
        return new Post($row);
    }
}
?>

Gateway


Mapper

 'id',
            'title' => 'title',
            'body'  => 'body',
        ];
    }
}
?>

Usage

setProfiler($profiler);
    return $pdo;
});

$query = new ConnectedQueryFactory(new QueryFactory('sqlite'));

$gateway_filter = new Filter();
$gateway = new PostGateway($connection_locator, $query, $gateway_filter);

$object_factory = new PostFactory();
$mapper_filter = new Filter();
$mapper = new PostMapper($gateway, $object_factory, $mapper_filter);
?>

Insert

 null,
    'title' => 'Hello aura',
    'body' => 'Some awesome content',
));

$mapper->insert($object);
?>

Note: the Mapper insert method assumes the primay column returned by getPrimaryCol is autogenerated by the database unless your concrete implementation of AbstractMapper overrides the isAutoPrimary method and returns a boolean false method. You will need to create to implement isAutoPrimary if you want to insert rows which contain values for the primary column., (*7)

fetchObject

<?php
$post = $mapper->fetchObject(
    $mapper->select()->where('id = ?', 1)
);
?>

fetchObjectBy

<?php
$post = $mapper->fetchObjectBy('id', 1);
?>

fetchCollection

<?php
$posts = $mapper->fetchCollection(
    $mapper->select()->where('id < ?', 11)
);
?>

fetchCollectionBy

<?php
$posts = $mapper->fetchCollectionBy('id', [1, 2, 3]);
?>

Update

<?php
$post = $mapper->fetchObjectBy('id', 1)
$post->title = 'Changed the title';
$mapper->update($post);
?>

Update only changes

fetchObjectBy('id', 1)

$post = clone $initial;
$post->body = 'Changed the body';

$mapper->update($post, $initial);
?>

Delete

<?php
$post = $mapper->fetchObjectBy('id', 1);
$mapper->delete($post);
?>

Object and Collection Factory

By default the mapper returns standard class objects. You can change this behaviour when creating the mapper, by extending ObjectFactory or by implmenting ObjectFactoryInterface., (*8)

newObject($row);
        }
        return $coll;
    }
}

$object_factory new PostFactory();
$mapper_filter = new Filter();
$mapper = new PostMapper($gateway, $object_factory, $mapper_filter);
?>

Override identity field

By default, mapper assumes a public property as the identity field (or one that appears public via the magic __set() method). If the individual object uses a different property name, or uses a method instead, override setIdentityValue method to provide setter functionality., (*9)

Example :, (*10)

setId($value);
    }
    // more code
}
?>

Filters

Filters can be used to alter the values during insert and update operations. Filter provides two methods which can be overridden, forInsert($subject) and forUpdate($subject). $subject may be passed as either an object or an array, so your code should be prepared to handle both., (*11)

The Versions

08/03 2016

2.x-dev

2.9999999.9999999.9999999-dev http://auraphp.github.com/Aura.SqlMapper_Bundle

A SQL DataMapper implementation.

  Sources   Download

BSD-2-Clause

The Requires

 

sql mapper data

01/04 2015

0.0.1

0.0.1.0 http://auraphp.github.com/Aura.SqlMapper_Bundle

A SQL DataMapper implementation.

  Sources   Download

BSD-2-Clause

The Requires

 

sql mapper data

30/01 2015

dev-assortment

dev-assortment http://auraphp.github.com/Aura.SqlMapper_Bundle

A SQL DataMapper implementation.

  Sources   Download

BSD-2-Clause

The Requires

 

sql mapper data

11/01 2015

dev-gateway

dev-gateway http://auraphp.github.com/Aura.SqlMapper_Bundle

A SQL DataMapper implementation.

  Sources   Download

BSD-2-Clause

The Requires

 

sql mapper data