定制 dflydev/identity-generator-dbal 二次开发

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

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

dflydev/identity-generator-dbal

Composer 安装命令:

composer require dflydev/identity-generator-dbal

包简介

Provides a Doctrine DBAL implementation of the identity generator data store.

README 文档

README

Provides a Doctrine DBAL implementation of the identity generator data store. For more information see: dflydev/identity-generator

Requirements

  • PHP 5.3+
  • Doctrine DBAL 2.2.*

Implementation Details

This simple dflydev/identity-generator Data Store implementation relies on blindly inserting records into a database.

It works under the assumption that if the underlying database has a unique constraint configured for either an identity column or a unique constraint configured for both and identity and mob column an exception will be thrown.

It attempts to capture this exception and determine whether or not there is a fault in the underlying connection or if it was due to a constraint violation. It does this by way of looking for ANSI SQL Error State Code 23000.

Schemas

The following are very naive examples of database schemas that will work with this data store. They may work for you for testing but please do not blindly use them for production.

SQLite

If mobs are not required simply create a table with one column marked as unique.

CREATE TABLE identity (
    identity string(64) unique
);

If mobs are required create a table with two columns and create a unique constraint across both columns.

CREATE TABLE identityWithMob (
    identity string(64),
    mob string(64),
    constraint id unique (identity, mob)
);

Mysql

If mobs are not required simply create a table with one column marked as unique.

CREATE TABLE identity (
    identity varchar(64) unique
);

If mobs are required create a table with two columns and create a unique index across both columns.

CREATE TABLE identityWithMob (
    identity varchar(64),
    mob varchar(64),
    unique index (identity, mob)
);

Usage

use Dflydev\IdentityGenerator\DataStore\Dbal\DataStore;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\DriverManager;

$config = new Configuration();
$connectionParams = array(); // driver specific connection configuration
$connection = DriverManager::getConnection($connectionParams, $config);

// Create a Data Store that does not support a mob.
$dataStore = new DataStore(
    $connection,
    'tableName',
    'identityColumnName'
);

// Create a Data Store that supports a mob.
$dataStoreWithMob = new DataStore(
    $connection,
    'tableName',
    'identityColumnName',
    'mobColumnName'
);

License

This library is licensed under the New BSD License - see the LICENSE file for details.

Community

If you have questions or want to help out, join us in the #dflydev channel on irc.freenode.net.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-06-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固