79 $sql =
"WITH marydoneCand AS ( 80 SELECT * FROM license_candidate 83 SELECT DISTINCT ON(rf_pk) * FROM 85 NATURAL FULL JOIN marydoneCand) 87 rf.rf_shortname, rf.rf_fullname, rf.rf_text, rc.rf_shortname parent_shortname, 88 rr.rf_shortname report_shortname, rf.rf_url, rf.rf_notes, rf.rf_source, 89 rf.rf_risk, gp.group_name 90 FROM allLicenses AS rf 91 FULL JOIN groups AS gp ON gp.group_pk = rf.group_fk 92 LEFT JOIN license_map mc ON mc.rf_fk=rf.rf_pk AND mc.usage=$2 93 LEFT JOIN license_ref rc ON mc.rf_parent=rc.rf_pk 94 LEFT JOIN license_map mr ON mr.rf_fk=rf.rf_pk AND mr.usage=$3 95 LEFT JOIN license_ref rr ON mr.rf_parent=rr.rf_pk 96 WHERE rf.rf_detector_type=$1";
97 $param = array(1, LicenseMap::CONCLUSION, LicenseMap::REPORT);
99 $stmt = __METHOD__ .
'.rf';
101 $sql .=
' AND rf.rf_pk = $'.count($param);
102 $row = $this->
dbManager->getSingleRow($sql,$param,$stmt);
103 $vars = $row ? array( $row ) : array();
106 $sql .=
' ORDER BY rf.rf_pk';
108 $res = $this->
dbManager->execute($stmt,$param);
109 $vars = $this->
dbManager->fetchAll( $res );
113 $out = fopen(
'php://output',
'w');
116 'shortname',
'fullname',
'text',
'parent_shortname',
'report_shortname',
117 'url',
'notes',
'source',
'risk',
'group');
118 fputcsv($out, $head, $this->delimiter, $this->enclosure);
119 foreach ($vars as $row) {
120 fputcsv($out, $row, $this->delimiter, $this->enclosure);
122 $content = ob_get_contents();
__construct(DbManager $dbManager)
createCsv($rf=0)
Create the CSV from the DB.
Helper class to export license list as a CSV from the DB.
Utility functions for specific applications.
setDelimiter($delimiter=',')
Update the delimiter.
fo_dbManager * dbManager
fo_dbManager object
setEnclosure($enclosure='"')
Update the enclosure.