forked from NYCPlanning/edm-metadata-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpmd_dict.php
More file actions
40 lines (37 loc) · 1.23 KB
/
expmd_dict.php
File metadata and controls
40 lines (37 loc) · 1.23 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
<?php
require 'vendor/autoload.php';
include 'config.php';
use League\HTMLToMarkdown\HtmlConverter;
$sde_underscore = $_GET['sde_underscore'];
// Connect to the Database
if (isset($_POST["Expor2md"])) {
//get records from database
header('Content-Type: text/md;');
header('Content-Disposition: attachment; filename='.$sde_underscore .'.md'); //this dowloads the csv file with the given name
//opening the md file to be downloaded
$fp = fopen("php://output", "w");
$html = '| order | field_name | longform_name | description | geocoded | required | data_type | expected_allowed_values | last_modified_date | no_longer_in_use | notes |<br />';
$html .= '| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |<br />';
$q = 'SELECT * FROM '.$sde_underscore . ' ORDER BY uid';
$query = pg_query($q);
//fetching values to write into the md file
while ($row = pg_fetch_row($query))
{
$count = count($row);
for ($y = 0; $y < $count; $y+=1)
{
if ($y == 0) {
}else {
$c_row = current($row);
$html.= "|" . $c_row;
}
next($row);
}
$html .= "<br />";
}
$converter = new HtmlConverter();
$markdown = $converter->convert($html);
echo $markdown;
fclose($fp);
}
?>