pan-roman/ifx4dd-plus 问题修复 & 功能扩展

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

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

pan-roman/ifx4dd-plus

Composer 安装命令:

composer require pan-roman/ifx4dd-plus

包简介

Informix Platform for Doctrine DBAL

README 文档

README

The Informix Platform for Doctrine DBAL gives support for Informix to Doctrine\DBAL the database abstraction layer of the Doctrine project.

DBAL versions supported

DBAL ifx4dd
master master Build Status
2.6 1.1 Build Status
2.5 1.0 Build Status

Informix versions supported

Tested on Informix Dynamic Server versions 11.70 and 12.10 (right now it's not tested on 11.50 but should work anyway).

INSTALL

If you don't already have the PDO_INFORMIX extension for PHP you need install it (see PDO_INFORMIX), make sure that the extension works correctly before continue, you can do a quick connection test to your Informix server using the next example

    <?php

    $dsn = 'informix:'
        . 'host=hosttest1;'
        . 'server=test1tcp;'
        . 'database=test_database;'
        . 'protocol=onsoctcp;'
        . 'service=50000;';

    $user = 'your_user';
    $password = 'your_password';

    $con = new PDO($dsn, $user, $password);

    if ($con) {
      echo "The connection was successfully established\n";
    }

You also will need composer in order to install all the dependencies, if you don't have it install it first.

Install from the repository

Download the code of the Informix Platform for Doctrine DBAL or clone it with git git clone https://github.com/josemalonsom/Ifx4dd.git. Move to the directory where you have the sources and install dependencies with composer

    $ cd Ifx4dd/
    $ composer install

it will install Doctrine\DBAL under the vendor directory and will create an autoloader class that you can find in the vendor/autoload.php file. The autoloader will add the Informix Platform directories in first place so that you can use the Informix Platform specific versions of some of the DBAL classes.

Install with composer

Simply execute:

    composer require "josemalonsom/ifx4dd:dev-master"

it will install the libraries under the vendor directory.

Getting a connection with Informix

If you don't have experience with DBAL please read first its documentation Doctrine\DBAL documentation

To create a connection you can use the modified version of the DriverManager of Doctrine\DBAL with comes with the Informix Platform or you can use the original DriverManager class of Doctrine\DBAL, in this last case you will need to specify the driver class to use.

Creating a connection with the modified version of the DriverManager

Ifx4dd comes with a modified version of the DriverManager class that adds pdo_informix as one of the possible drivers to use.

In this case, you need tell to composer that load the classes from the ifx4dd directory tree in first place (if you have installed ifx4dd from the composer.json what comes with ifx4dd it is not needed since the ifx4dd directory is added in first place to the autoloader).

    <?php

    // Gets the autoloader
    $classLoader = require_once 'vendor/autoload.php';

    // Adds the ifx4dd directory in first place to the
    // Doctrine\DBAL namespace
    $classLoader->add(
        'Doctrine\\DBAL\\',
        'vendor/josemalonsom/ifx4dd/lib',
        true
    );

    use Doctrine\DBAL\DriverManager;

    $connectionParams = array(
        'driver'       => 'pdo_informix',
        'host'         => 'hosttest1',
        'port'         => '50000',
        'protocol'     => 'onsoctcp',
        'server'       => 'test1tcp',
        'dbname'       => 'test_database',
        'user'         => 'user',
        'password'     => 'password',
        'db_locale'     => 'ru_RU.1251', // optional
        'client_locale'     => 'ru_RU.1251', // optional
    );

    $connection = DriverManager::getConnection($connectionParams);

Creating a connection with the original DriverManager of DBAL

If you want to use the 'Doctrine\DBAL\DriverManager' class what comes with DBAL you need to specify the driver class to use in the connection params as in the next example:

    <?php

    require_once 'vendor/autoload.php';

    use Doctrine\DBAL\DriverManager;

    $connectionParams = array(
        'driverClass'  => '\Doctrine\DBAL\Driver\PDOInformix\Driver',
        'host'         => 'hosttest1',
        'port'         => '50000',
        'protocol'     => 'onsoctcp',
        'server'       => 'test1tcp',
        'dbname'       => 'test_database',
        'user'         => 'user',
        'password'     => 'password',
        'db_locale'     => 'ru_RU.1251', // optional
        'client_locale'     => 'ru_RU.1251', // optional
    );

    $connection = DriverManager::getConnection($connectionParams);

Creating a connection with a URL

Since DBAL 2.5 it is possible to use a URL to create the connection (note that in this case you must use the ifx4dd DriverManager version).

    <?php

    $classLoader = require_once 'vendor/autoload.php';

    $classLoader->add(
        'Doctrine\\DBAL\\',
        'vendor/josemalonsom/ifx4dd/lib',
        true
    );

    use Doctrine\DBAL\DriverManager;

    $connection = DriverManager::getConnection(array(
        'url' => 'informix://user:password@hosttest1:50000/test_database?protocol=onsoctcp&server=test1tcp'
    ));

Please, refer to the DBAL documentation for more information: https://github.com/doctrine/dbal/blob/2.5/docs/en/reference/configuration.rst

Delimited identifiers

DBAL uses delimited identifiers so you need to enable it in your Informix environment, see enabling delimited identifiers.

Other documentation

pan-roman/ifx4dd-plus 适用场景与选型建议

pan-roman/ifx4dd-plus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「persistence」 「dbal」 「queryobject」 「doctrine」 「informix」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 pan-roman/ifx4dd-plus 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pan-roman/ifx4dd-plus 我们能提供哪些服务?
定制开发 / 二次开发

基于 pan-roman/ifx4dd-plus 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-28