forked from spotweb/spotweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexportmc.php
More file actions
62 lines (55 loc) · 2.12 KB
/
exportmc.php
File metadata and controls
62 lines (55 loc) · 2.12 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
<?php
error_reporting(2147483647);
/*
* We need loads of memory to make sure we can cache everything, preventing
* us from going to the database too often
*/
ini_set('memory_limit', '2048M');
try {
/*
* If we are run from another directory, try to change the current
* working directory to a directory the script is in
*/
if (@!file_exists(getcwd() . '/' . basename($argv[0]))) {
chdir(dirname(__FILE__));
} # if
require_once "lib/SpotClassAutoload.php";
SpotClassAutoload::register();
require_once "lib/Bootstrap.php";
/*
* Create a DAO factory. We cannot use the bootstrapper here,
* because it validates for a valid settings etc. version.
*/
$bootstrap = new Bootstrap();
list($settings, $daoFactory, $req) = $bootstrap->boot();
/* Retrieve the current list */
$conn = $daoFactory->getConnection();
$resultList = $conn->arrayQuery("SELECT DISTINCT ON (mc.title, mc.year)
mc.id AS mcid,
mc.title,
mc.tmdb_id,
mc.cattype,
mc.year
FROM mastercollections mc
LEFT JOIN collections c ON c.mcid = mc.id
WHERE cattype = 3
AND tmdb_id IS NULL");
# $lists = array_chunk($resultList, ceil(count($resultList) / 4));
$lists = array($resultList); // 1 one list
for($i = 0; $i < count($lists); $i++) {
file_put_contents('export' . $i . '.serialize', serialize($lists[$i]));
} // for
/*
* And actually start updating or creating the schema and settings
*/
echo "Done exporting collections" . PHP_EOL;
}
catch(Exception $x) {
echo PHP_EOL . PHP_EOL;
echo 'SpotWeb crashed' . PHP_EOL . PHP_EOL;
echo "Export of collections failed:" . PHP_EOL;
echo " " . $x->getMessage() . PHP_EOL;
echo PHP_EOL . PHP_EOL;
echo $x->getTraceAsString();
die(1);
} # catch