定制 kachit/doctrine-datamapper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kachit/doctrine-datamapper

最新稳定版本:3.2.0

Composer 安装命令:

composer require kachit/doctrine-datamapper

包简介

Simple datamapper powered by doctrine 2 dbal

README 文档

README

License Build Status codecov Latest Stable Version Total Downloads

Simple datamapper powered by doctrine2

<?php
//create database connection
$params = [
    'driver' => 'pdo_pgsql',
    'host' => '127.0.0.1',
    'port' => 5432,
    'dbname' => 'db',
    'user' => 'postgres',
    'password' => '',
];
$connection = Doctrine\DBAL\DriverManager::getConnection($params);
<?php
//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);
<?php
//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);

统计信息

  • 总下载量: 9.3k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-25