-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow.php
executable file
·48 lines (38 loc) · 1.04 KB
/
show.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
#!/usr/local/bin/php
<?php
require 'vendor/autoload.php';
require_once __DIR__ . '/lib/db.php';
require(__DIR__."/lib/autoload.php");
array_shift($argv);
$collection = ucfirst(array_shift($argv));
print $collection."\n";
if (file_exists("lib/{$collection}.php")) {
include __DIR__."/lib/{$collection}.php";
}
$obj = new $collection();
// $results = $campaign->create($newCampaign);
//print_r($results);
if (count($argv)) {
$out = [];
// Read
while ($id = array_shift($argv)) {
$p = preg_split("/=/", $id, 2);
if (count($p)) {
$id = $obj->findId([$p[0]=>$p[1]]);
print $id."\n";
$out = $obj->get($id);
} else {
$out = [];
}
}
//print_r($allCampaigns);
} else {
$out = $obj->read();
}
print_r($obj);
print json_encode($out, JSON_PRETTY_PRINT);
// Update
//$campaignId = 'INSERT_CAMPAIGN_ID_HERE'; // replace with an actual campaign ID
//$campaign->update($campaignId, ['title' => 'Updated Campaign Title']);
// Delete
//$campaign->delete($campaignId);