todd999
11-15-2007, 10:36 PM
We use Crystal Reports to mine data in many local databases on our network.
It would be great if we could press a button in a Cerb plug-in that would export the raw data so we can download a copy to our local network and run crystal against it.
I know there must be a techie way to get a local copy of the data but for the people who run reports each day it would be too complex to require a coder for each export.
This way users can crate and share report templates in a format many already use.
If we can do this it might crate a vibrant user community of report trading.
Our Goal is to run a report by customer (email address) across our Order manager (access DB) and also Cerb4
Thoughts?
-Todd
mfogg
02-25-2008, 09:36 PM
Your question hasn't been replied to in awhile so I'll mention some thoughts. You're right that usually the techie way of getting a local DB copy is plenty for many people. Using the mysqldump command from the command line gives you a text file from which you could easily recreate the db.
Are you just trying to find a good way to automate the downloading of the data into some kind of user friendly tabular form? There's always the possibility of programatically calling mysqldump from within a new plugin in PHP like:
<?php
echo system('mysqldump -h localhost -u mydbusername -pmypassword mydbname');
?>
The users could save the resulting output to a file, but they would still need to run the script on their local machine installation of MySQL manually, which makes me think if they could handle that they probably could just handle getting the mysql dump from the server via the command line themselves in the first place without having to use a cerberus plugin.
We do something similar here using php, here's the basic steps required to create a downloadable csv file you could then process using your favorite tools:
First, run a query to select your data, then run a loop to convert it to csv rows. Example:
while ($RowsReported < $Rows) {
$Date = mysql_result($Resultset,$RowsReported,"leadsdisposition.date") ;
$LeadNumber = mysql_result($Resultset,$RowsReported,"leads.code") ;
$FirstName = mysql_result($Resultset,$RowsReported,"leads.firstname") ;
$LastName = mysql_result($Resultset,$RowsReported,"leads.lastname") ;
$Address = mysql_result($Resultset,$RowsReported,"leads.address") ;
$City = mysql_result($Resultset,$RowsReported,"leads.city") ;
$County = mysql_result($Resultset,$RowsReported,"leads.county") ;
$State = mysql_result($Resultset,$RowsReported,"leads.state") ;
$Result = mysql_result($Resultset,$RowsReported,"dispositioncodes.dispositioncode") ;
$Data = $Data . "\"$LeadNumber\",\"$Date\",\"$FirstName\",\"$LastName\",\"$Address\",\"$City\",\"$County\",\"$State\"" . "\n" ;
$RowsReported++ ;
}
Then serve up the resulting data in a downloadable file:
if ($Data != "") {
header("Pragma: ") ;
header("Cache-Control: ") ;
header("Content-Type: application/octet-stream") ;
header("Content-Length: " . strlen($Data)) ;
header("Content-Disposition: attachment; filename=\"dispatchdetail.csv\"") ;
print "$Data" ;
}
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.