1. Go to this page and download the library: Download aura/sqlmapper-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aura / sqlmapper-bundle example snippets
use Aura\SqlMapper_Bundle\ObjectFactory;
class Post
{
public $id;
public $title;
public $body;
public function __construct(array $data = array())
{
foreach ($data as $field => $value) {
$this->$field = $value;
}
}
}
class PostFactory extends ObjectFactory
{
public function newObject(array $row = array())
{
return new Post($row);
}
}
use Aura\SqlMapper_Bundle\AbstractGateway;
class PostGateway extends AbstractGateway
{
public function getTable()
{
return 'posts';
}
public function getPrimaryCol()
{
return 'id';
}
}
use Aura\SqlMapper_Bundle\AbstractMapper;
class PostMapper extends AbstractMapper
{
public function getIdentityField()
{
return 'id';
}
public function getColsFields()
{
return [
'id' => 'id',
'title' => 'title',
'body' => 'body',
];
}
}
use Aura\Sql\ConnectionLocator;
use Aura\Sql\ExtendedPdo;
use Aura\SqlMapper_Bundle\Query\ConnectedQueryFactory;
use Aura\SqlMapper_Bundle\Filter;
use Aura\SqlQuery\QueryFactory;
use Aura\Sql\Profiler;
$profiler = new Profiler();
$connection_locator = new ConnectionLocator(function () use ($profiler) {
$pdo = new ExtendedPdo('sqlite::memory:');
$pdo->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);
use Aura\SqlMapper_Bundle\ObjectFactoryInterface;
use Aura\SqlMapper_Bundle\Filter;
class PostFactory implements ObjectFactoryInterface
{
public function newObject(array $row = array())
{
return new Post($row);
}
public function newCollection(array $rows = array())
{
$coll = array();
foreach ($rows as $row) {
$coll[] = $this->newObject($row);
}
return $coll;
}
}
$object_factory new PostFactory();
$mapper_filter = new Filter();
$mapper = new PostMapper($gateway, $object_factory, $mapper_filter);
namespace Vendor\Package;
use Aura\SqlMapper_Bundle\AbstractMapper;
class PostMapper extends AbstractMapper
{
public function setIdentityValue($object, $value)
{
$object->setId($value);
}
// more code
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.