承接 kristoreed/laminas-dictionary 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

kristoreed/laminas-dictionary

Composer 安装命令:

composer require kristoreed/laminas-dictionary

包简介

Laminas dictionary

README 文档

README

Laminas-dictionary is repository class with simple CRUD functionality, which can be used as base to more complex db dictionaries. This package base on kristoreed/laminas-db-manager

Installation

Use the package manager composer to install laminas-dictionary.

composer require kristoreed/laminas-dictionary

Base usage

use Kristoreed\Laminas\DbManager\Query\Executor\Executor as QueryExecutor;

$dbAdapter = new Adapter([
    'driver'    => 'pdo',
    'dsn'       => 'mysql:dbname=test;host=localhost',
    'username'  => 'admin',
    'password'  => 'admin',
]);

$queryExecutor = new QueryExecutor($dbAdapter);
$userRepository = new Dictionary($queryExecutor);
$userRepository->setTableName('users');
$user = $userRepository->getElementById(404);

Extend usage

class User extends Dictionary implements UserInterface
{
    /**
     * @var string
     */
    protected $tableName = 'users';

    /**
     * @var QueryExecutorInterface
     */
    protected $queryExecutor;

    /**
     * User constructor
     *
     * @param QueryExecutorInterface $queryExecutor
     */
    public function __construct(QueryExecutorInterface $queryExecutor)
    {
        parent::__construct($queryExecutor);
        $this->queryExecutor = $queryExecutor;
    }

    /**
     * @param string $elementEmail
     *
     * @return array
     *
     * @throws ExecutorException
     */
    public function getElementByEmail(string $elementEmail): array
    {
        $select = new Select();
        $select
            ->from(['u' => $this->tableName])
            ->columns(['*'])
            ->where([
                'email' => $elementEmail
            ]);

        return $this->queryExecutor->getRow($select);
    }
}

$dbAdapter = new Adapter([
    'driver'    => 'pdo',
    'dsn'       => 'mysql:dbname=test;host=localhost',
    'username'  => 'admin',
    'password'  => 'admin',
]);

$queryExecutor = new QueryExecutor($dbAdapter);
$userRepository = new User($queryExecutor);
$user = $userRepository->getElementByEmail("user404@gmail.com");

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固