|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-04-03 14:10 UTC] djogopatrao at gmail dot com
Description:
------------
In order to verify this, you need
1) crystal reports XI version 2 (free download for trial at www.businessobjects.com)
2) access to a database
3) a report that uses data from this database
the code above hangs when invoking the ReadRecords method. A equivalent code was tested and worked OK under Visual Fox Pro.
thanks
dfcp
Reproduce code:
---------------
$my_report = "c:\\report1.rpt";
$my_pdf = "c:\\report1.pdf";
$ObjectFactory= New COM("CrystalReports115.ObjectFactory.1");
$crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");
$creport = $crapp->OpenReport($my_report, 1);
$creport->ReadRecords(); //hangs here
$creport->ExportOptions->DiskFileName=$my_pdf;
$creport->ExportOptions->PDFExportAllPages=true;
$creport->ExportOptions->DestinationType=1; // Export to File
$creport->ExportOptions->FormatType=31; // Type: PDF
$creport->Export(false);
Expected result:
----------------
It would create a file (name $my_pdf) with the report.
Actual result:
--------------
It hangs.
PatchesCrystalReport_php_support (last revision 2013-10-18 10:13 UTC by yr dot bhavsar at gmail dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 18 18:00:01 2025 UTC |
I modified slightly the code (see below, I called it hang.php) Running thru apache2, it hangs. No response from the browser (it's still "loading", started 2h ago). No entries in "error.log" since then. Commenting the $creport->ReadRecords(); line, it works. But when running by PHP CLI C:\>"Arquivos de programas\Apache Group\Apache2\bin\php.exe" hang.php C:\> It runs just fine! --------- hang.php $my_report = 'C:\Arquivos de programas\Apache Group\Apache2\htdocs\webdisc\relatorios\cadastro1.rpt'; $my_pdf = 'c:\18530.pdf'; $ObjectFactory= New COM("CrystalReports115.ObjectFactory.1"); $crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application"); $creport = $crapp->OpenReport($my_report, 1); $creport->ReadRecords(); //hangs here, not thru PHPCLI $creport->ExportOptions->DiskFileName=$my_pdf; $creport->ExportOptions->PDFExportAllPages=true; $creport->ExportOptions->DestinationType=1; // Export to File $creport->ExportOptions->FormatType=31; // Type: PDF $creport->Export(false);i work with Crystal Report 10 and i work only onnce time. When i try again, i get the following error:Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Crystal Reports ActiveX Designer<br/><b>Description:</b> Unbekannter Abfragemodulfehler' in C:\xampp\htdocs\neu\BescheinigungPDF.php:28 Stack trace: #0 C:\xampp\htdocs\neu\BescheinigungPDF.php(28): variant->LogOnServer('p2sifmx', 'name', 'name', 'acc', 'pass') #1 C:\xampp\htdocs\neu\BescheinigungPDF.php(123): BescheinigungPDF->getPDF('20062', 99898989) #2 {main} thrown in C:\xampp\htdocs\neu\BescheinigungPDF.php on line 28 my code: function getPDF($sem,$mtknr){ // Create an Crystal Object Factory. $o_CrObjectFactory = new COM('CrystalReports10.ObjectFactory.1')or die ("Error on load"); try { $o_CrApplication = $o_CrObjectFactory->CreateObject("CrystalRunTime.Application"); } catch (com_exception $e){ echo("<br>Error on instance creation:<br>".$e->getMessage().'<p>'.$e->getTraceAsString().'</p>'); echo "<p><pre>".print_r($e, true)."</pre></p>"; exit; } // Register the typelibrary. com_load_typelib('CrystalDesignRunTime.Application'); // Load the report. $o_CrReport = $o_CrApplication->OpenReport('C:\xampp\apache\Studienbescheinigung.rpt', 1);// 1== crOpenReportByTempCopy. $o_CrReport->Database->LogOnServer('p2sifmx', 'name', 'name', 'acc', 'pass'); $o_CrReport->DisplayProgressDialog = False; $s_ExportedReport = 'C:\xampp\apache\test.pdf'; var_dump($o_CrReport->RecordSelectionFormula); $str = "{sossys.aktsem} = $sem and {sos.mtknr} = $mtknr"; $o_CrReport->RecordSelectionFormula=$str; var_dump($o_CrReport->RecordSelectionFormula); // Run the report and save the PDF to disk. $o_CrReport->ExportOptions->DiskFileName = $s_ExportedReport; $o_CrReport->ExportOptions->PDFExportAllPages = true; $o_CrReport->ExportOptions->DestinationType = 1; // Export to File $o_CrReport->ExportOptions->FormatType = 31; // 31 = PDF, 36 = XLS, 14 =DOC $o_CrReport->EnableParameterPrompting = 0; $o_CrReport->DiscardSavedData; //remove die saved Datei $o_CrReport->ReadRecords(); //force it to update the data in the report from the ADO.command,(Does not work). $o_CrReport->Export(false); $o_CrReport=null; $o_CrApplication = null; $o_CrObjectFactory=null; print "...done"; var_dump($o_CrReport->RecordSelectionFormula); /*****/ } My chef think, i shoul programm in java but every thing i worked with php(my programm work for an card terminal). Should i make an connection between php and java to call my crystal report? Please help me, thank you very much!!!