Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

mini cleanup of examples

  • Loading branch information...
commit e4e9107aec3d1e0c914e40436f77fed0e5df2485 1 parent 43aa00f
Jan jsteemann authored
18 examples/collection.php
View
@@ -2,23 +2,7 @@
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 => 9000,
- ConnectionOptions::OPTION_HOST => "localhost",
- ConnectionOptions::OPTION_TIMEOUT => 3,
- ConnectionOptions::OPTION_TRACE => $traceFunc,
- ConnectionOptions::OPTION_CREATE => false,
- ConnectionOptions::OPTION_UPDATE_POLICY => "last",
-);
+require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
try {
$connection = new Connection($connectionOptions);
17 examples/document.php
View
@@ -2,23 +2,8 @@
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 {
$connection = new Connection($connectionOptions);
22 examples/init.php
View
@@ -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 examples/select.php
View
@@ -2,7 +2,7 @@
namespace triagens\Avocado;
-require dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php';
+require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
/* set up some example statements */
$statements = array(
@@ -17,19 +17,6 @@
"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 {
$connection = new Connection($connectionOptions);
Please sign in to comment.
Something went wrong with that request. Please try again.