-
Notifications
You must be signed in to change notification settings - Fork 1
/
select-user.php
58 lines (34 loc) · 1.04 KB
/
select-user.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
<?php
require_once(__DIR__.'/arangodb.php');
use ArangoDBClient\Statement as ArangoStatement;
//echo "<br>";
//echo "<center><h2>This is the user list:</h2></center>";
$userId = $_GET['id']; //it uses for me to get the data inside the link "localhost/all/nosql/test/get-user.php?id=A/UR14201/10"
//echo $userId; // to chack
$stmt = new ArangoStatement(
$arangodb,
[
'query' => 'FOR user IN @@collection
FILTER user._key == @key RETURN user',
'bindVars' => [
'@collection' => 'users' ,
'key' => $userId
]
]
);
$cursor = $stmt -> execute();
//print_r($cursor -> getAll()); is used to show only using the value id
$data = $cursor -> getAll();
if( count($data) == 0 ){
echo '<br>';
echo ' <center>Sorry There Is No ID That Similar To This!</center>';
exit();
}
$user = $data[0];
header('Content-Type: application/json'); // using display json format
http_response_code(200); //display using json format
echo $user;
try{
}catch(Exception $ex){
echo $ex;
}