定制 trf4php/trf4php-doctrine 二次开发

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

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

trf4php/trf4php-doctrine

最新稳定版本:2.0.0

Composer 安装命令:

composer require trf4php/trf4php-doctrine

包简介

This is a Doctrine binding for trf4php.

README 文档

README

Latest Stable Version

master: Build Status Coverage Status 1.2: Build Status Coverage Status

This is a Doctrine binding for trf4php

Using trf4php-doctrine

Configuration

<?php
/* @var $em \Doctrine\ORM\EntityManager */
$tm = new DoctrineTransactionManager($em);

Using transactions

<?php
/* @var $tm TransactionManager */
try {
    $tm->beginTransaction();
    // database modifications
    $tm->commit();
} catch (TransactionException $e) {
    $tm->rollback();
}

Transactional EntityManager

If a transaction fails, you have to close your EntityManager. Doctrine says that after closing an EM, you have to create another one if you want to use database. TransactionalEntityManagerReloader does it automatically.

To enable this feature, you have to do the following steps:

  • Use EntityManagerProxy in DoctrineTransactionManager
  • Attach TransactionalEntityManagerReloader observer to DoctrineTransactionManager
$tm = new DoctrineTransactionManager(new DefaultEntityManagerProxy());
$emFactory = new DefaultEntityManagerFactory($conn, $config);
$tm->attach(new TransactionalEntityManagerReloader($emFactory));

If you would like to use a shared, non-transactional EntityManager, pass it to the constructor of DefaultEntityManagerProxy. In this case you can use the proxy object without starting a transaction, which is not recommended, but sometimes necessary.

This feature is also useful in integration tests. You can rollback in tearDown() thus you don't need to reinitialize the database. It highly speed-up your tests.

History

1.2

Transactional EntityManager

Create an EntityManager right after you start a transaction.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-12-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固