Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
fix: decode base64 value
Browse files Browse the repository at this point in the history
  • Loading branch information
moechofe committed Mar 24, 2011
2 parents 25ebd36 + 2fbdac0 commit 1d38bb1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
22 changes: 13 additions & 9 deletions README.md
@@ -1,22 +1,26 @@
A PHP5.3+ API for Kyoto Tycoon
==============================

Experimental API to communicate with a [Kyoto Tycoon](http://fallabs.com/kyototycoon/) server.
Experimental API and UI to communicate with a [Kyoto Tycoon](http://fallabs.com/kyototycoon/) server.
Using RPC protocol for now, but I'm plan to implement Rest and binary protocol too.

Short example using the UI:

<?php
// Start a server with the command line: ktserver
$kt->kt('http://localhost:1978');
require_once 'kyoto-tycoon.php';
// Get an UI object an clear the database
$kt = kt()->clear;
// Setting records
$kt->set('日本','東京')
->set('france','paris');
// Getting a record
$city = $kt->get('日本');
$city = $kt->france;
$kt['日本'] = '東京';
$kt->set('Coruscant','Coruscant');
$kt->France('Paris');
// Getting records
echo $kt['日本'],PHP_EOL;
echo $kt->get('Coruscant'),PHP_EOL;
echo $kt->France,PHP_EOL;
// Browsing records
foreach( $kt as $k => $v )
echo "country:$k city:$v";
foreach( $kt->forward() as $k => $v )
echo "country:$k city:$v",PHP_EOL;

Look at the _test.php_ script for more examples.
23 changes: 20 additions & 3 deletions doc/kyoto-tycoon.html 100644 → 100755
Expand Up @@ -12,16 +12,33 @@
<body>
<div class="document">
<h2 class="title">PhpKyotoTycoon - API to communicate with a KT server</h2>
<h1><em>&laquo;&nbsp;Un outil pour les diriger tous&nbsp;&raquo;</em></h1>
<h1><em>&laquo;&nbsp;Provided for easy and powerful programming related to database and web.&nbsp;&raquo;</em></h1>
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/09/Network-server.svg/120px-Network-server.svg.png" align="right" style="margin-left:1em" />
<p>This tool is used to manipulate the records of a <em>Koyto Tycoon</em> server. It require a PHP5.3 version or more.Here is a list of cons and pros:&nbsp;</p>
<p>This tool is used to manipulate the records of a <em>Kyoto Tycoon</em> server. It require a PHP5.3 version or more. Here is a list of cons and pros:&nbsp;</p>
<ul style="clear:left">
<li><strong>Two ways to work with</strong>: close to the protocol and easy to use from PHP.</li>
<li>Support <strong>iterator</strong> and <strong>array access</strong> to browse the records.</li>
<li><hr/></li>
<<<<<<< HEAD
<li>No support for Rest and binary protocol yet.</li>
<li>Lot of commands's still not implemented.</li>
=======
<li>No support for Rest and binary protocol now.</li>
>>>>>>> 2fbdac0c05847d8944e2499bbb924c19b47d37dd
</ul>
<span id="quickstart" class="anchor"></span>
<h3>Quick start</h3>
<p>Copy the file <tt>kyoto-tycoon.php</tt> somewhere and include it in your application:&nbsp;</p>
<pre name="code" class="php:nocontrols">require_once 'kyoto-tycoon.php';</pre>
<p>Instanciate the class <tt>UI</tt> with the function <tt>kt()</tt>:&nbsp;</p>
<pre name="code" class="php:nocontrols">$kt = kt();</pre>
<p>Parameters list are discribed in the documentation of the <a href="#func_var">kt()</a> function.</p>
<span id="access" class="anchor"></span>
<h3>Accessing records</h3>
<p></p>
<pre name="code" class="php:nocontrols">$kt['France'] = 'Paris';</pre>


<!--
Ce outil de requêtage pour <em>Oracle</em> permet envoyer des requêtes et de récupérer les résultats. Il se comporte comme une couche d'abstraction aux drivers <em>PHP</em>&nbsp;: <em>OCI8</em>, <em>SqlRelay</em> et <em>PDO_OCI</em>. Voici ses avantages&nbsp;:</p>
<ul style="clear:left">
Expand Down Expand Up @@ -162,6 +179,7 @@ <h1><em>&laquo;&nbsp;Un outil pour les diriger tous&nbsp;&raquo;</em></h1>
<dt>LOB</dt>
<dd>Développer un mecanisme interne pour gérer les <em>Large Object</em> de façon transparente à la manière de <em>SqlRelay</em>.</dd>
</dl>
-->
<script language="javascript" src="shCore.js"></script>
<script language="javascript" src="shBrushPhp.js"></script>
<script language="javascript">
Expand All @@ -175,7 +193,6 @@ <h1><em>&laquo;&nbsp;Un outil pour les diriger tous&nbsp;&raquo;</em></h1>
<li><a class="anchor" href="#row">Ligne par ligne</a></li>
<li><a class="anchor" href="#field">Colonne</a></li>
</ul>
-->
</div>
</body>
</html>
23 changes: 10 additions & 13 deletions test.php
Expand Up @@ -11,7 +11,7 @@

skip_ok();

test(/*
test(
// {{{ Test simple operations

'Test simple operations: get,set,clear,replace,add,append,remove', function()
Expand Down Expand Up @@ -76,30 +76,25 @@

'Test match_prefix and match_regex', function()
{
plan(16);
plan(17);
$kt = new KyotoTycoon\API(server_uri);
ok( $kt->clear );
var_dump(__LINE__);
ok( $kt->set('a.b.c','ananas,banana,citrus') );
ok( $kt->set('a.c.b','ananas,citrus,banana') );
ok( $kt->set('b.c.a','banana,citrus,ananas') );
ok( $kt->set('b.a.c','banana,ananas,citrus') );
var_dump(__LINE__);
isanarray( $r=$kt->match_prefix('a.') );
has( $r, 2 );
var_dump(__LINE__);
ok( false!==array_search('a.b.c', $r) );
ok( false!==array_search('a.c.b', $r) );
isanarray( $r=$kt->match_prefix('b.') );
var_dump(__LINE__);
has( $r, 2 );
ok( false!==array_search('a.c.b', $r) );
ok( false!==array_search('b.a.c', $r) );
ok( false!==array_search('b.c.a', $r) );
var_dump(__LINE__);
isanarray( $r=$kt->match_regex('\w\.c\.\w') );
has( $r, 1 );
var_dump(__LINE__);
has( $r, 2 );
ok( false!==array_search('a.c.b', $r) );
ok( false!==array_search('b.c.a', $r) );
},

// }}}
Expand Down Expand Up @@ -168,7 +163,7 @@

'Test fluent and quick interface', function()
{
plan(45);
plan(47);
$kt = kt(server_uri);
isnull( $kt->clear->c );
ok( $kt->a('ananas') );
Expand Down Expand Up @@ -199,7 +194,9 @@
is( $kt->inc('i',2), 3 );
is( $kt->inc('f',0.1), 0.1 );
is( $kt->inc('f',0.2), 0.3 );
is( $kt->set('a','akira')->cat('a',' kurozawa')->get('a'), 'akira kurozawa' );
ok( $kt->set('a','akira') );
ok( $kt->cat('a',' kurozawa') );
is( $kt->get('a'), 'akira kurozawa' );
notok( $kt->add('a','alien') );
ok( $kt->rep('a','alien') );
ok( $kt->del('a') );
Expand All @@ -216,7 +213,7 @@

// }}}
// {{{ Test ArrayAccess
*/

'Test ArrayAccess', function()
{
plan(6);
Expand Down
10 changes: 4 additions & 6 deletions zimple-test.php
Expand Up @@ -258,7 +258,7 @@ function notexcept( $callback, $exception, $msg = 'Shouldn\'t throw an exception
}

// }}}
// {{{ isaboolean, isaboolean, isaninteger, isnotaninteger, isastring, isnotastring, isanobject, isnotanobject, isanarray, isnotanarray, isaresource, isnotaresource
// {{{ isaboolean, isnotaboolean, isaninteger, isnotaninteger, isastring, isnotastring, isanobject, isnotanobject, isanarray, isnotanarray, isaresource, isnotaresource

/**
* Test if a value is a boolean or not
Expand Down Expand Up @@ -472,11 +472,9 @@ function compare( $test, $operator, $expected, $msg )
diag( sprintf('# obtained: %s %s', str_repeat(' ',strlen($operator)), $test) );
diag( sprintf('# expected: %s %s', $operator, $expected) );
if( extension_loaded('xdebug') )
{
list($call) = array_slice(xdebug_get_function_stack(),-2,1);
if( in_array($call['function'],array('ok','notok')) and ! empty($call['file']) and ! empty($call['line']) )
diag( sprintf('# at line: %s of file: %s', $call['line'], $call['file']) );
}
foreach( array_reverse(xdebug_get_function_stack()) as $call )
if( ! empty($call['file']) and $call['file'] != __FILE__ and ! empty($call['function']) and in_array($call['function'],array('ok','notok','is','isnt','truly','trulynot','greater','notgreater','lesser','notleser','contain','notcontain','has','hasnt','isa','isnota','like','notlike','except','notexcept','isaboolean','isnotaboolean','isaninteger','isnotaninteger','isastring','isnotastring','isanobject','isnotanobject','isanarray','isnotanarray','isaresource','isnotaresource')) and ! empty($call['line']) )
{ diag( sprintf('# at line: %s of file: %s', $call['line'], $call['file']) ); break; }
}
return $ok;
}
Expand Down

0 comments on commit 1d38bb1

Please sign in to comment.