1. Go to this page and download the library: Download kachit/doctrine-datamapper 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/ */
//create your table gateway
class FooGateway extends Kachit\Database\Gateway
{
/**
* @return string
*/
public function getTableName(): string
{
return 'users';
}
}
$gateway = new FooGateway($connection);
//fetch by PK
$row = $gateway->fetchByPk(1);
//fetch all without filter
$rows = $gateway->fetchAll();
//fetch list with filter (all active)
$filter = new Kachit\Database\Query\Filter();
$filter->createCondition('active', true);
$rows = $gateway->fetchAll($filter);
//create entity
class FooEntity extends Kachit\Database\Entity
{
/**
* @var int
*/
protected $id;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return FooEntity
*/
public function setId(int $id)
{
$this->id = $id;
return $this;
}
}
//create mapper
$gateway = new FooGateway();
$entity = new FooEntity();
$mapper = new Kachit\Database\Mapper($gateway, $entity);
//fetch by PK
$entity = $mapper->fetchByPk(1);
//fetch all without filter
$collection = $mapper->fetchAll();
//fetch list with filter (all active)
$filter = new Kachit\Database\Query\Filter();
$filter->createCondition('active', true);
$collection = $mapper->fetchAll($filter);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.