airmoi/yii2-fmconnector

FileMaker ODBC 和 PHP-API 集成

安装次数: 1,639

依赖项: 0

建议者: 0

安全性: 0

星标: 7

关注者: 4

分支: 1

开放问题: 3

类型:yii2-extension

2.5 2020-06-29 13:31 UTC

README

FileMaker ODBC 连接器和 PHP-API 集成

安装

安装此扩展的首选方法是通过 composer

运行以下命令之一:

php composer.phar require --prefer-dist airmoi/yii2-fmconnector "*"

或者在您的 composer.json 文件的 require 部分添加以下内容:

"airmoi/yii2-fmconnector": "*"

使用方法

  1. ODBC 连接

使用 composer 安装插件并配置服务器上的 ODBC 驱动后,使用以下命令创建或编辑您的数据库配置文件:

return [
    'class' => 'airmoi\yii2fmconnector\db\Connection',
    'dsn' => 'fmp:<odbc_connection_name>',
    'username' => '<odbc_username>',
    'password' => '<odbc_username>',
    'charset' => 'utf8',
    'pdoClass' => 'airmoi\yii2fmconnector\db\PDO',
    //'enableSchemaCache' => true,
    //'schemaCacheDuration' => 86400,
    //'enableQueryCache' => true,
    //'queryCacheDuration' => 1000,
    'schemaMap' => ['fmp' => [
            'class' => 'airmoi\yii2fmconnector\db\Schema',
            /* 
             * Customize this option to ignore specific fields (like global/utils fields) which you don't want to get access
             * Ignore theses fields improve query performences
             */
            'ignoreFields' => [
                'FieldType' => ['global%'],
                'FieldClass' => ['Summary'],
                'FieldName' => ['zkk_%',
                    'zgi_%',
                    'zg_%',
                    'zz_%',
                    'zzz_%',
                    'zlg_%',
                    'z_foundCount_cU',
                    'z_listOf_eval_cU',
                ]
            ],
            /* 
             * Regexp pattern used to detect if a field is a primary key
             * this pattern while be used against fields names
             */
            'primaryKeyPattern' => '/^zkp(_)?/',
            /* 
             * pattern used to detect if a field is a foreign key
             * this pattern while be used against fields names
             * Second match of the pattern must return the foreign key trigram (XXX)
             */
            'foreignKeyPattern' => '/^(zkf|zkp)_([^_]*).*/', //pattern used to detect if a field is a foreign key
        ]
    ]
];
  1. PHP-API

您还可以使用以下方式通过 PHP-API 配置连接:

[
    'class' => 'airmoi\yii2fmconnector\api\Connection',
    'dsn' => 'fmpapi:host=your_host_ip;dbname=your_db_name',
    'username' => 'db username',
    'password' => 'db passwod',
    'charset' => 'utf8',
    //'schemaCache' => 'cache',
    //'enableSchemaCache' => true,
    //'schemaCacheDuration' => 3600,
    'options' => [ //Specific connector options
        'dateFormat' => 'd/m/Y',
        'emptyAsNull' => true,
    ],
    'schemaMap' => [
        'fmpapi' => [
            'class' => 'airmoi\yii2fmconnector\api\Schema',
            //'layoutFiltterPattern' =>  '/^PHP_/' //Regex pattern to filter layout's list
        ]
    ]
]
  1. 自定义 gii

将以下行添加到 gii 模块配置中,以增强模型和 CRUD 生成器:

'generators' => [
        'model' => [
        'class' => 'yii\gii\generators\model\Generator',
        'templates' => [
            'FileMakerAPI' => '@app/vendor/airmoi/yii2-fmconnector/gii/api/templates/',
            'FileMakerODBC' => '@app/vendor/airmoi/yii2-fmconnector/gii/odbc/templates/',
        ]
    ],
     'crud' => [ // generator name
        'class' => 'airmoi\yii2fmconnector\gii\api\crud\Generator', // generator class
        /*'templates' => [ //setting for out templates
            'myCrud' => '@app/myTemplates/crud/default', // template name => path to template
        ]*/
    ]
],