-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
75 lines (52 loc) · 1.59 KB
/
test.php
File metadata and controls
75 lines (52 loc) · 1.59 KB
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
66
67
68
69
70
71
72
73
74
75
<?php
require_once './vendor/autoload.php';
require_once './src/includes/functions.php';
use HardeepVicky\Json\JsonDatabase;
JsonDatabase::showErrorAsHtml(true);
$json_database = JsonDatabase::getInstance("./data_files", "users", [
"attributes" => [
"created" => true,
"updated" => true,
]
]);
$json_database->setRequiredAttributes(["name", "age", "dob"]);
$json_database->setUniqueAttributes(["name"]);
//$update_count = $json_database->update(["name" => "Elroy Pingree"], ["primary_key" => 2]);
//dump($update_count, true);
// for($i = 1; $i <= 2; $i++)
// {
// $json_database->insert([
// "name" => get_random_name(),
// "age" => mt_rand(5,60),
// "dob" => get_random_date_time()
// ]);
// }
$records = $json_database->get();
dump($records);
//$records = $json_database->filter($records, [], ["name" => null]);
$records = $json_database->filter($records, [], ["age" => function($index, $record, $key)
{
if ($record[$key] < 25)
{
return false;
}
}], "age", "desc");
dump($records);
$info_records = JsonDatabase::getInfo("./data_files");
dump($info_records);
$attr_info_records = JsonDatabase::getAttributeInfo("./data_files");
dump($attr_info_records);
exit;
/*
$json_database->update(["name" => "vicky", "age" => 28], ["name" => "vicky"]);
$records = $json_database->get();
dump($records);
$records = $json_database->filter($records, [], ["name" => function($index, $record, $key)
{
if (is_null($record[$key]))
{
return false;
}
}], "age", "asc");
dump($records);
*/