blob: 6c06322648ba53b92a7ecc4cb83b1cb579d819d2 (
plain)
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
|
<?php
/**
* Cinisis - Isis db reading tool.
*/
// Import Cinisis Library.
require_once '../index.php';
// Get a db instance.
$isis = new CinisisDb();
// Test connection.
if ($isis->db) {
// Get format and number of rows.
$rows = $isis->db->rows();
$format = $isis->db->format;
// Prepare output.
header("Content-type: application/text/x-csv");
header("Content-Disposition: attachment; filename=export.csv");
header("Pragma: no-cache");
header("Expires: 0");
// Format fields.
foreach ($format['fields'] as $field) {
echo $field['name'] .',';
if (is_array($field['subfields'])) {
foreach ($field['subfields'] as $key => $value) {
echo $field['name'] .': '. $value.',';
}
}
}
// Format output.
for ($n=1; $n <= $rows; $n++) {
$result = $isis->db->read($n);
foreach ($format['fields'] as $field) {
echo $result[$field['name']] .',';
if (is_array($field['subfields'])) {
foreach ($field['subfields'] as $key => $value) {
echo $result[$field['name']][$value] .',';
}
}
}
echo "\n";
}
}
|