Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions examples/collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,42 @@
try {
$connection = new Connection($connectionOptions);
$handler = new CollectionHandler($connection);

// create a new collection
$col = new Collection();
$col->setName("hihi");
$result = $handler->add($col);
var_dump($result);

// get an existing collection
$result = $handler->get("hihi");
var_dump($result);

// get an existing collection
$result = $handler->get("hihi");
var_dump($result);

// get number of documents from an existing collection
$result = $handler->getCount("hihi");
var_dump($result);

// get figures for an existing collection
$result = $handler->getFigures("hihi");
var_dump($result);

// delete the collection
$result = $handler->delete("hihi");
var_dump($result);

// rename a collection
// $handler->rename($col, "hihi30");

// truncate an existing collection
// $result = $handler->truncate("hihi");
}
catch (ConnectException $e) {
} catch (ConnectException $e) {
print $e . PHP_EOL;
}
catch (ServerException $e) {
} catch (ServerException $e) {
print $e . PHP_EOL;
}
catch (ClientException $e) {
} catch (ClientException $e) {
print $e . PHP_EOL;
}
11 changes: 4 additions & 7 deletions examples/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
unset($userFromServer->name);
$result = $handler->update($userFromServer);
var_dump($result);

// get the updated document back
$result = $handler->get("users", $id);
var_dump($result);
Expand All @@ -51,13 +51,10 @@
$result = $handler->deleteById("users", $id);
var_dump($result);

}
catch (ConnectException $e) {
} catch (ConnectException $e) {
print $e . PHP_EOL;
}
catch (ServerException $e) {
} catch (ServerException $e) {
print $e . PHP_EOL;
}
catch (ClientException $e) {
} catch (ClientException $e) {
print $e . PHP_EOL;
}
6 changes: 2 additions & 4 deletions examples/graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@
$result1 = $graphHandler->removeEdge('Graph', 'edge1');
} catch (ConnectException $e) {
print $e . PHP_EOL;
}
catch (ServerException $e) {
} catch (ServerException $e) {
print $e . PHP_EOL;
}
catch (ClientException $e) {
} catch (ClientException $e) {
print $e . PHP_EOL;
}
1 change: 0 additions & 1 deletion examples/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@
ConnectionOptions::OPTION_CREATE => false, // do not create unknown collections automatically
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST, // last update wins
);

17 changes: 7 additions & 10 deletions examples/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

foreach ($statements as $query => $bindVars) {
$statement = new Statement($connection, array(
"query" => $query,
"count" => true,
"batchSize" => 1000,
"bindVars" => $bindVars,
"query" => $query,
"count" => true,
"batchSize" => 1000,
"bindVars" => $bindVars,
"sanitize" => true,
));

Expand All @@ -30,13 +30,10 @@
$cursor = $statement->execute();
var_dump($cursor->getAll());
}
}
catch (ConnectException $e) {
} catch (ConnectException $e) {
print $e . PHP_EOL;
}
catch (ServerException $e) {
} catch (ServerException $e) {
print $e . PHP_EOL;
}
catch (ClientException $e) {
} catch (ClientException $e) {
print $e . PHP_EOL;
}
2 changes: 1 addition & 1 deletion lib/triagens/ArangoDb/AdminHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@ public function getServerRequestStatistics($options = array())

return $data;
}
}
}
2 changes: 1 addition & 1 deletion lib/triagens/ArangoDb/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function init()
self::checkEnvironment();

self::$libDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;

spl_autoload_register(__NAMESPACE__ . '\Autoloader::load');
}

Expand Down
8 changes: 4 additions & 4 deletions lib/triagens/ArangoDb/BatchPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function getProcessedResponse()
$json = $response->getJson();
$id = $json[Edge::ENTRY_ID];
$response = $json;
$options = $this->getCursorOptions();
$options = $this->getCursorOptions();
$options['isNew'] = false;
$response = Edge::createFromArray($json, $options);
break;
Expand All @@ -275,7 +275,7 @@ public function getProcessedResponse()
$json = $response->getJson();
$id = $json[Collection::ENTRY_ID];
$response = $json;
$options = $this->getCursorOptions();
$options = $this->getCursorOptions();
$options['isNew'] = false;
$response = Collection::createFromArray($json, $options);
break;
Expand All @@ -287,7 +287,7 @@ public function getProcessedResponse()
}
break;
case 'cursor':
$options = $this->getCursorOptions();
$options = $this->getCursorOptions();
$options['isNew'] = false;
$response = new Cursor($this->_batch->getConnection(), $response->getJson(), $options);
break;
Expand All @@ -309,4 +309,4 @@ private function getCursorOptions()
{
return $this->_cursorOptions;
}
}
}
6 changes: 3 additions & 3 deletions lib/triagens/ArangoDb/CollectionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public function create($collection, $options = array())
* @param string $type - index type: hash, skiplist or geo
* @param array $attributes - an array of attributes that can be defined like array('a') or array('a', 'b.c')
* @param bool $unique - true/false to create a unique index
* @param array $indexOptions - an associative array of options for the index like array('geoJson' => true)
* @param array $indexOptions - an associative array of options for the index like array('geoJson' => true)
*
* @return mixed - id of collection created
*/
Expand All @@ -397,9 +397,9 @@ public function index($collectionId, $type = "", $attributes = array(), $unique
self::OPTION_FIELDS => $attributes,
self::OPTION_UNIQUE => $unique
);

$bodyParams = array_merge($bodyParams, $indexOptions);

$url = UrlHelper::appendParamsUrl(Urls::URL_INDEX, $urlParams);
$response = $this->getConnection()->post($url, $this->json_encode_wrapper($bodyParams));

Expand Down
2 changes: 1 addition & 1 deletion lib/triagens/ArangoDb/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ private function executeRequest($method, $url, $data)
// call tracer func
$traceFunc('receive', $result);
}

if ($status['timed_out']) {
throw new ClientException('Got a timeout when waiting on the server\'s response');
}
Expand Down
78 changes: 39 additions & 39 deletions lib/triagens/ArangoDb/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ class Document
* @var bool
*/
protected $_changed;
/**
* Flag to indicate whether document is a new document (never been saved to the server)
*
* @var bool
*/

/**
* Flag to indicate whether document is a new document (never been saved to the server)
*
* @var bool
*/
protected $_isNew = true;

/**
Expand All @@ -80,10 +80,10 @@ class Document
* Revision id index
*/
const ENTRY_REV = '_rev';
/**
* isNew id index
*/

/**
* isNew id index
*/
const ENTRY_ISNEW = '_isNew';

/**
Expand Down Expand Up @@ -123,10 +123,10 @@ public function __construct(array $options = array())
if (array_key_exists('_hiddenAttributes', $options)) {
$this->setHiddenAttributes($options['_hiddenAttributes']);
}

if (array_key_exists('_isNew', $options)) {
$this->setIsNew($options['_isNew']);
}
}
}

/**
Expand Down Expand Up @@ -277,11 +277,11 @@ public function set($key, $value)

return;
}
if ($key === self::ENTRY_ISNEW) {
$this->setIsNew($value);
return;

if ($key === self::ENTRY_ISNEW) {
$this->setIsNew($value);

return;
}

if (!$this->_changed) {
Expand Down Expand Up @@ -452,28 +452,28 @@ public function getChanged()
{
return $this->_changed;
}
/**
* Set the isNew flag
*
* @param bool $isNew - flags if new or existing doc
*
* @return void
*/
public function setIsNew($isNew)
{
$this->_isNew = (bool)$isNew;
}
/**
* Get the isNew flag
*
* @return bool $isNew - flags if new or existing doc
*/
public function getIsNew()
{
return $this->_isNew;
}

/**
* Set the isNew flag
*
* @param bool $isNew - flags if new or existing doc
*
* @return void
*/
public function setIsNew($isNew)
{
$this->_isNew = (bool)$isNew;
}

/**
* Get the isNew flag
*
* @return bool $isNew - flags if new or existing doc
*/
public function getIsNew()
{
return $this->_isNew;
}

/**
* Set the internal document id
Expand Down
Loading