survey/enterQuestions.php

51 lines
1.9 KiB
PHP

<?php
use ArangoDBClient\CollectionHandler;
use ArangoDBClient\Connection;
use ArangoDBClient\ConnectionOptions;
use ArangoDBClient\DocumentHandler;
use ArangoDBClient\UpdatePolicy;
require "config.php";
require "vendor/autoload.php";
$connectionOptions = array(
// server endpoint to connect to
//ConnectionOptions::OPTION_ENDPOINT => 'tcp://10.16.17.154:8529',
ConnectionOptions::OPTION_ENDPOINT => 'tcp://' . $server . ':8529',
// authorization type to use (currently supported: 'Basic')
ConnectionOptions::OPTION_AUTH_TYPE => 'Basic',
// user for basic authorization
ConnectionOptions::OPTION_AUTH_USER => $dbuser,
// password for basic authorization
ConnectionOptions::OPTION_AUTH_PASSWD => $passwd,
// connection persistence on server. can use either 'Close' (one-time connections) or 'Keep-Alive' (re-used connections)
ConnectionOptions::OPTION_CONNECTION => 'Close',
// connect timeout in seconds
ConnectionOptions::OPTION_TIMEOUT => 3,
// whether or not to reconnect when a keep-alive connection has timed out on server
ConnectionOptions::OPTION_RECONNECT => true,
// optionally create new collections when inserting documents
ConnectionOptions::OPTION_CREATE => true,
// optionally create new collections when inserting documents
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST,
ConnectionOptions::OPTION_DATABASE => $database,
);
// open connection
$connection = new Connection($connectionOptions);
$collectionHandler = new CollectionHandler($connection);
$documentHandler = new DocumentHandler($connection);
/*
$input = 0;
while($input != 99){
$input = readline("Frage: ");
if ($input != 99){
$question = new Document();
$question->set('question', $input);
$question->set('type', 'schülerawards');
$documentHandler->insert($collectionHandler->get("questions"), $question);
}
}
*/