-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathss.php
More file actions
executable file
·44 lines (37 loc) · 1.07 KB
/
ss.php
File metadata and controls
executable file
·44 lines (37 loc) · 1.07 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
<?php
require_once('vendor/autoload.php');
class compare
{
protected $json;
protected $fromDB;
public function loadInternalData($dbHostname, $dbName, $dbUsername, $dbPassword = null)
{
$pdo = new PDO(sprintf('mysql:host=%s;dbname=%s', $dbHostname, $dbName), $dbUsername, $dbPassword);
$stm = $pdo->prepare('select id from `my_data`');
$stm->execute();
foreach ($stm->fetchAll() as $row) {
$this->fromDB[] = $row['id'];
}
}
public function loadExternalData($jsonDataFilePath)
{
foreach (json_decode(file_get_contents($jsonDataFilePath)) as $row) {
$this->json[] = $row->id;
}
}
public function check()
{
$compared = array_intersect($this->json, $this->fromDB);
foreach ($compared as $id) {
echo "$id\n";
}
}
}
$bench = new Ubench();
$bench->start();
$compare = new compare();
$compare->loadInternalData('localhost', 'ss', 'root');
$compare->loadExternalData('data.json');
$compare->check();
$bench->end();
echo $bench->getTime();