Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Home

moechofe edited this page · 10 revisions
Clone this wiki locally

« Provided for easy and powerful programming related to database and web. »

This PHP tool is used to manipulate the records of a Kyoto Tycoon server. It require a PHP5.3 version or more. Here is a list of cons and pros:

  • Two ways to work with: close to the protocol and easy to use from PHP.
  • Support iterators and array access to browse the records.
  • Partial support of Rest protocol and no binary protocol yet.
  • Lot of commands's still not implemented. TODO: list it

QuickStart

Copy the script lib.kyoyo.php somewhere and include it in your application:

<?php
require_once 'lib.kyoyo.php';

Add an alias for the namespace \qad\kyoto or remove the namespace declaration:

<?php
use qad\kyoto;

Instanciate the class kyoto\UI with the function kyoto\UI():

<?php
$kt = kyoto\UI();

Parameters list is described in the documentation of the kyoto\UI() function.

Accessing records

The UI object supports 3 ways to set and get records.

  • Using the object like an Array:

    <?php
    $kt['France'] = 'Paris';
    var_dump( $kt['France'] );
  • Using the set() and get() methods:

    <?php
    $kt->set('日本', '東京');
    var_dump( $kt->get('日本') );
  • Using the magic methods:

    <?php
    $kt->Japan('Tokyo');
    var_dump( $kt->Japan );

Read the documentation about the UI class to learn all the available ways to access records.

Browsing records

There is many ways to browse records: keys and values, keys only, forward, backward, matching keys by prefix or by a regular expression.

  • All records:

    <?php
    foreach( $kt->forward() as $key => $value )
    var_dump( $key, $value );
  • All records in the reverse order:

    <?php
    foreach( $kt->backward() as $key => $value )
    var_dump( $key, $value );
  • All records that begin with a prefix:

    <?php
    foreach( $kt->begin('prefix_') as $key => $value )
    var_dump( $key, $value );
  • All records that match a regular expression:

    <?php
    foreach( $kt->regex('.*_match_.*') as $key => $value )
    var_dump( $key, $value );

Read the documentation about the UI class to learn all the available ways to browse records.

Configuration

The configuration may alter the behavior of the code. Change it carefully.

  • Unexisting records return null:

    By default an exception was thrown when trying to access or delete an unexisting records. Use outofbound_return_null to change this behavior. If you do need to change permanently, clone the object before.

    <?php
    $kt->outofbound_return_null;
    var_dump( $kt['unexists'] ); // display NULL
    unset($kt['unexists']); // do not throw exception
  • Connection error return false:

    The connection was not establish until a command needs to be send on the server. Thats mean probably when the first records of the session was accessed. When the connection could'nt be established, an exception was throw by default. Use runtime_return_false to change this behavior.

    <?php
    $kt = new kyoto\UI('http://not.a.server');
    $kt->runtime_return_false;
    var_dump( $kt['exist'] ); // display FALSE

Documentations

Something went wrong with that request. Please try again.