-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoin.php
65 lines (54 loc) · 1.99 KB
/
join.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'vendor/autoload.php';
ini_set('opcache.enable', '0');
use GraphAware\Neo4j\Client\ClientBuilder;
if ($_POST){
$client = ClientBuilder::create()
->addConnection('default', 'http://neo4j:neo4j@localhost:7474') // Example for HTTP connection configuration (port is optional)
->build();
// $client->run('CREATE (n:Event) SET n += {infos}', ['infos' => ['name' => $_POST['name'], 'age' => $_POST['age'],
// 'gender' => $_POST['gender'], 'telephone' => $_POST['telephone']]]);
$query = 'MATCH (s:Person)
WHERE ID(s) = {person_id}
MATCH (n:Event)
WHERE ID(n) = {event_id}
CREATE (n)<-[:JOINED {is_:0}]-(s)
RETURN n';
$parameters = [
'person_id' => (int) $_POST['person_id'],
'event_id' => (int) $_POST['event_id'],
];
$client->run($query, $parameters);
echo 'Added record!';
}
//this part, show all the person and event information , and create a drop down menu
$client = ClientBuilder::create()
->addConnection('default', 'http://neo4j:neo4j@localhost:7474')
->build();
$query = 'MATCH (n:Event) RETURN n.name as name, ID(n) as id';
$result = $client->run($query);?>
<form action="join.php" method="POST">
Join which event:
<select name="event_id">
<?php foreach ($result->getRecords() as $record) {?>
<option value="<?php echo $record->value('id');?>"><?php echo $record->value('name');?></option>
<?php }?>
</select>
<br>
<?php $client = ClientBuilder::create()
->addConnection('default', 'http://neo4j:neo4j@localhost:7474')
->build();
$query = 'MATCH (n:Person) RETURN n.name as name, ID(n) as id';
$result = $client->run($query);?>
Who will join event:
<select name="person_id">
<?php foreach ($result->getRecords() as $record) {?>
<option value="<?php echo $record->value('id');?>"><?php echo $record->value('name');?></option>
<?php }?>
</select>
<br>
<input type="submit">
</form>