vaffel/dao 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

vaffel/dao

Composer 安装命令:

composer require vaffel/dao

包简介

PHP Data Access Object library

README 文档

README

The DAO library makes interacting with database objects easy and abstracts away the hassle of keeping memcached and elasticsearch data up to date when making changes to the data.

Installation

Add "vafel/dao": "dev-master" to the dependencies list of your project.

Setup

Before the DaoFactory is used to retrieve DAO instances, the DAO must be set up;

// Set up read only mysql
Vaffel\Dao\DaoFactory::setServiceLayer(
    Vaffel\Dao\DaoFactory::SERVICE_MYSQL,
    Vaffel\Dao\Models\Dao\MySQL::DB_TYPE_RO,
    $roPdo // PDO instance, with read-only access
);

// Set up read+write mysql
Vaffel\Dao\DaoFactory::setServiceLayer(
    Vaffel\Dao\DaoFactory::SERVICE_MYSQL,
    $rwPdo, // PDO instance, with write access
    Vaffel\Dao\Models\Dao\MySQL::DB_TYPE_RW
);

In addition to the RO and RW MySQL service, elasticsearch and memcached service layers needs to be set up;

Vaffel\Dao\DaoFactory::setServiceLayer(
    Vaffel\Dao\DaoFactory::SERVICE_MEMCACHED,
    $memcached // Memcached instance
);

Vaffel\Dao\DaoFactory::setServiceLayer(
    Kidsa\DaoFactory::SERVICE_ELASTIC_SEARCH,
    $elasticClient // Elastica\Client instance
);

Usage

After the initial setup, you can retrieve DAO instances for classes in your application by statically calling getDao on the DaoFactory class.

$userDao = DaoFactory::getDao('MyApplication\Models\User');

// Return user with id 1337
$user = $userDao->fetch(1337);

// Set first name on the returned user
$user->setFirstName('Kristoffer');

// Persist the updated user object
$userDao->save($user);

The class name of the DAO class is found by naively adding Dao\ after the last backslash in the model name.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2017-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固