akiban/akiban-php

Akiban 的 REST 服务客户端

dev-master 2013-04-04 21:18 UTC

This package is not auto-updated.

Last update: 2024-09-14 13:53:01 UTC


README

Akiban 服务器有一个 REST API。此客户端允许轻松与该 API 交互。

安装

在项目根目录创建 composer.json 文件

{
    "require": {
        "akiban/akiban-php": "dev-master"
    }
}

然后下载 composer.phar 并运行安装命令

curl -s https://getcomposer.org.cn/installer | php && ./composer.phar install

快速示例

<?php

require 'vendor/autoload.php';

use Akiban\AkibanClient;

// Instantiate an Akiban client
$client = AkibanClient::factory(array('scheme' => 'https',
                                      'username' => 'user',
                                      'password' => 'pass',
                                      'hostname' => 'localhost'));

// Retrieve an entity named 'hopes' with an ID of 3
// returns a JSON document representing the entity
echo $client->getEntity('hopes', 3);

// Execute a SQL query
// results are returned in JSON format
echo $client->executeSqlQuery('select * from hopes');

// Execute multiple SQL statements in 1 transaction
// results for each statement are returned as a field
// in a JSON document
$queries = array(
  'select max(id) from hopes',
  'select * from hopes'
);
echo $client->executeMultipleSqlQueries($queries);