rjakes / rjakessimplefm

soliantconsulting/simplefm 的包装器

2.0.0beta04 2014-09-18 16:45 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:05:46 UTC


README

包装器/外观,扩展了 Jeremiah Small 的 SimpleFM 类,用于与 FileMaker Server 进行通信

https://github.com/soliantconsulting/SimpleFM

这个类是 SimpleFM 的便利包装,提供了快速简单的 CRUD 操作,以及非常简单的方法从 PHP 中执行 FileMaker 脚本。这对于不想或不需要构建 FileMaker Web Pushing 引擎所需的查询参数的程序员非常有帮助。

作者 Roger Jacques - roger@rjakes.com

系统要求

  • PHP 5.3+
  • FileMaker Server 12+

通过简单示例快速入门

以下快速入门文件将与 FileMaker Server 安装的 FMServer_Example 文件一起工作,并且它们将与未经修改的 fuelPHP 一起工作。获取所需类的方法最好的方式是在创建新的 fuelPHP 项目后,在项目文件夹根目录下找到 composer.json 文件并添加一个条目。

    "require": {
        "php": ">=5.3.3",
        "composer/installers": "~1.0",
        "fuel/docs": "1.7.2",
        "fuel/core": "1.7.2",
        "fuel/auth": "1.7.2",
        "fuel/email": "1.7.2",
        "fuel/oil": "1.7.2",
        "fuel/orm": "1.7.2",
        "fuel/parser": "1.7.2",
        "fuelphp/upload": "2.0.1",
        "monolog/monolog": "1.5.*",
        "michelf/php-markdown": "1.4.0",
		"rjakes/rjakessimplefm": "dev-master"
    },

然后,从您的项目目录中运行

composer.phar update

这些示例可以在任何可以加载所需类的项目或框架中工作,修改最小(下面的控制器有一些 fuelPHP 特定的代码。)

基本模型

<?php
/*
 * This is a base model that exists in a single location to instantiate 
 * the connection to FileMaker.
 * All other models are extended from this model.
 *
 * There are other ways to instantiate an object, and if you understand them
 * then you probably don't need a quickstart from me.
 */

namespace Model;

use \rjakes\RjakesSimpleFM\Facade;

class BaseModel {

    public $fmpConn = FALSE;

    public function __construct()
    {
        $hostParams    = array(
                        'hostname'     => '127.0.0.1',
                        'dbname'        => 'FMServer_Sample',
                        'username'      =>  'admin',
                        'password'      =>  '');
        $this->fmpConn  = new Facade($hostParams);
    }

}

模型

<?php
/**
* This model extends the base class and the database connection.
*
**/

namespace Model;

use \Model\BaseModel;

class Language extends BaseModel {

    public function __construct()
    {
       // don't forget to call the parent constructor
       // else you will not get your connection object
       parent::__construct();

        // Set a default layout for this model, this can be overridden as needed.
        // The layout is a required parameter for all database interactions,
        // it sets the context, controling which table is queried,
        // dictating which fields are available for querying and which are 
        // returned.
       $this->fmpConn->setDefaultLayoutName('PHP Technology Test');

    }

    public function getStrings($language)
    {
        $language = 'SAMPLE_' . $language;
        
        $this->fmpConn->addWhereCriteria('LANGUAGE MATCH FIELD', $language, 'eq');
        
        // use the default layout that was set in the constructor of this class
        $result = $this->fmpConn->select();
        return $result;
    }


}

控制器

<?php
/**
* This is a fuelPHP controller, provided just to make the example complete.
* There is nothing here that is specific to RjakesSimpleFM
 */

use \Model\Language;

class Controller_Example extends Controller
{
    public $language = FALSE;

    public function before()
    {
        $this->language = new Language(); // grab an instance of the model

    }

	public function action_index()
	{

        $results['data']['getLanguage'] = $this->language->getStrings('German');

        return Response::forge(View::forge('welcome/index',								$results));         
	}

响应

// Here is what you get back from the model method call in the above controller.
// This structure is provided by SimpleFM.
Array
(
    [getLanguage] => Array
        (
            [url] => http://admin:[...]@192.168.0.11:80/fmi/xml/fmresultset.xml?-db=FMServer_Sample&-lay=PHP Technology Test&LANGUAGE+MATCH+FIELD=SAMPLE_German&LANGUAGE+MATCH+FIELD.op=eq&-find
            [error] => 0
            [errortext] => No error
            [errortype] => FileMaker
            [count] => 20
            [fetchsize] => 20
            [rows] => Array
                (
                    [0] => Array
                        (
                            [index] => 0
                            [recid] => 399
                            [modid] => 13
                            [LANGUAGE MATCH FIELD] => SAMPLE_German
                            [Task Name Sample] => Sitemap-Skizze
                            [Task Start Date Sample] => 03/19/2014
                            [Task Due Date Sample] => 05/02/2014
                            [Task Completion Percentage Sample] => 80
                        )

                    [1] => Array
                        (
                            [index] => 1
                            [recid] => 400
                            [modid] => 13
                            [LANGUAGE MATCH FIELD] => SAMPLE_German
                            [Task Name Sample] => Grafiken an Anbieter senden
                            [Task Start Date Sample] => 04/04/2014
                            [Task Due Date Sample] => 04/05/2014
                            [Task Completion Percentage Sample] => 0
                        )
                 )
          )
)

许可

RjakesSimpleFM 对商业和非商业使用都是免费的,许可协议为对商业友好的 MIT 许可证。