balefireeyed
Member
- Joined
- Sep 5, 2013
- Messages
- 53
- Reaction score
- 3
Successfully used the following php script a freepbx distro installation. I'm wondering what is preventing it from working on piaf purple.
The error that I'm getting when I run php file.php is this:
PHP:
#!/usr/bin/env php
<?php
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
include_once('/etc/asterisk/freepbx.conf');
}
$outfile = '/cdrreports/csvreport.csv';
$dbh = \FreePBX::Database();
$sql = "SELECT * FROM asteriskcdrdb.cdr WHERE date(calldate) >= date(now()-interval 1 day);";
$stmt = $dbh->prepare($sql);
$stmt->execute();
$ret = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$colnames = array_keys($ret[0]);
$csv = fopen($outfile,'w+');
fputcsv($csv,$colnames);
foreach($ret as $row){
fputcsv($csv,$row);
}
fclose($csv);
The error that I'm getting when I run php file.php is this:
Code:
PHP Fatal error: Class 'FreePBX' not found in /root/run_csv.php on line 7