Skip to content

Commit

Permalink
mini cleanup of examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jsteemann committed Apr 4, 2012
1 parent 43aa00f commit e4e9107
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 47 deletions.
18 changes: 1 addition & 17 deletions examples/collection.php
Expand Up @@ -2,23 +2,7 @@


namespace triagens\Avocado; namespace triagens\Avocado;


require dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php'; require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';

/* set up a trace function that will be called for each communication with the server */
$traceFunc = function($type, $data) {
print "TRACE FOR ". $type . PHP_EOL;
var_dump($data);
};

/* set up connection options */
$connectionOptions = array(
ConnectionOptions::OPTION_PORT => 9000,
ConnectionOptions::OPTION_HOST => "localhost",
ConnectionOptions::OPTION_TIMEOUT => 3,
ConnectionOptions::OPTION_TRACE => $traceFunc,
ConnectionOptions::OPTION_CREATE => false,
ConnectionOptions::OPTION_UPDATE_POLICY => "last",
);


try { try {
$connection = new Connection($connectionOptions); $connection = new Connection($connectionOptions);
Expand Down
17 changes: 1 addition & 16 deletions examples/document.php
Expand Up @@ -2,23 +2,8 @@


namespace triagens\Avocado; namespace triagens\Avocado;


require dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php'; require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';


/* set up a trace function that will be called for each communication with the server */
$traceFunc = function($type, $data) {
print "TRACE FOR ". $type . PHP_EOL;
var_dump($data);
};

/* set up connection options */
$connectionOptions = array(
ConnectionOptions::OPTION_PORT => 9000, // port to connect to
ConnectionOptions::OPTION_HOST => "localhost", // host to connect to
ConnectionOptions::OPTION_TIMEOUT => 3, // timeout in seconds
ConnectionOptions::OPTION_TRACE => $traceFunc, // tracer function
ConnectionOptions::OPTION_CREATE => false, // do not create unknown collections automatically
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST, // last update wins
);


try { try {
$connection = new Connection($connectionOptions); $connection = new Connection($connectionOptions);
Expand Down
22 changes: 22 additions & 0 deletions examples/init.php
@@ -0,0 +1,22 @@
<?php

namespace triagens\Avocado;

require dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php';

/* set up a trace function that will be called for each communication with the server */
$traceFunc = function($type, $data) {
print "TRACE FOR ". $type . PHP_EOL;
var_dump($data);
};

/* set up connection options */
$connectionOptions = array(
ConnectionOptions::OPTION_PORT => 8529, // port to connect to
ConnectionOptions::OPTION_HOST => "localhost", // host to connect to
ConnectionOptions::OPTION_TIMEOUT => 3, // timeout in seconds
ConnectionOptions::OPTION_TRACE => $traceFunc, // tracer function
ConnectionOptions::OPTION_CREATE => false, // do not create unknown collections automatically
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST, // last update wins
);

15 changes: 1 addition & 14 deletions examples/select.php
Expand Up @@ -2,7 +2,7 @@


namespace triagens\Avocado; namespace triagens\Avocado;


require dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php'; require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';


/* set up some example statements */ /* set up some example statements */
$statements = array( $statements = array(
Expand All @@ -17,19 +17,6 @@
"select u from users u where u.id == @id@ && u.name != @name@" => array("id" => 6, "name" => "fux"), "select u from users u where u.id == @id@ && u.name != @name@" => array("id" => 6, "name" => "fux"),
); );


/* set up a trace function that will be called for each communication with the server */
$traceFunc = function($type, $data) {
print "TRACE FOR ". $type . PHP_EOL;
var_dump($data);
};

/* set up connection options */
$connectionOptions = array(
ConnectionOptions::OPTION_PORT => 9000,
ConnectionOptions::OPTION_HOST => "localhost",
ConnectionOptions::OPTION_TIMEOUT => 3,
ConnectionOptions::OPTION_TRACE => $traceFunc,
);


try { try {
$connection = new Connection($connectionOptions); $connection = new Connection($connectionOptions);
Expand Down

0 comments on commit e4e9107

Please sign in to comment.