本文整理汇总了PHP中COM::LogOnServer方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::LogOnServer方法的具体用法?PHP COM::LogOnServer怎么用?PHP COM::LogOnServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COM
的用法示例。
在下文中一共展示了COM::LogOnServer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_pdf
private function print_pdf($query = "", $param = array(), $db)
{
if (file_exists($this->pdf_name)) {
if (!unlink($this->pdf_name)) {
echo "Failed to clear temp. please try again";
}
}
try {
$ObjectFactory = new COM("CrystalRunTime.Application") or die("cannot load cr com");
$creport = $ObjectFactory->OpenReport($this->rpt_name, 1) or die("Couldn’t open report");
$ObjectFactory->LogOnServer('PDSODBC.DLL', 'mysql_' . $db, $db, 'root', 'mysql');
//$creport->RecordSelectionFormula="{company.company_name}='AL RUSHAID CONSTRUCTION CO. LTD.'";
//$creport->RecordSelectionFormula="{ogmr.job_no}='530'";
$creport->RecordSelectionFormula = $query;
//$creport->RecordSelectionFormula= mysql_real_escape_string($query);
$creport->EnableParameterPrompting = 0;
$creport->DiscardSavedData;
$creport->ReadRecords();
if (count($param) > 0) {
for ($i = 1; $i <= count($param); $i++) {
$field = $creport->ParameterFields($i);
$end = strlen(substr($creport->ParameterFields($i)->Name, 2)) - 1;
$paramName = substr($field->Name, 2, $end);
$res = @$field->SetCurrentValue($param[$paramName]);
if ($res != 0) {
return "Failed to create report. Failed to set parameter {$i} with value " . $param[$i];
}
}
}
$creport->ExportOptions->DiskFileName = $this->pdf_name;
$creport->ExportOptions->FormatType = 31;
$creport->ExportOptions->DestinationType = 1;
$creport->Export(false);
$crapp = null;
$creport = null;
$ObjectFactory = null;
if (file_exists($this->pdf_name)) {
echo "true";
/*$pdf = file_get_contents($this->pdf_name);
if(strlen($pdf) != filesize($this->pdf_name))
return "Error: filesize=".filesize($this->pdf_name)." strlen=".strlen($pdf);
header("Pragma: ");
header("Cache-Control: ");
header("Content-type: application/pdf");
//header("Content-Disposition: attachment;filename=" . extractName($this->rpt_name) . ".pdf"); // For IE
header("Content-Disposition: attachment;filename=localhost/assets/pdf/company.pdf"); // For IE
echo($pdf);
exit();*/
} else {
echo "Failed to export";
}
} catch (Exception $e) {
echo "Failed to connect to Crystal Reports 2008: {$e}";
}
}
示例2: COM
<?php
set_time_limit(0);
//if(isset($_GET['id']))
//{
//$id = $_GET['id'];
//} else {
//die('Please specify an ID');
//}
$path = "D:\\MYrep";
//$file = $chemin."\\bill_".$id.".pdf";
$app_obj = new COM("CrystalRuntime.Application") or die("Did not open");
$report = $path . "\\1234.rpt";
$rpt_obj = $app_obj->OpenReport($report, 1);
$app_obj->LogOnServer("p2ssql.dll", "host", "bdd", "userbd", "passwordbd");
$rpt_obj->EnableParameterPrompting = FALSE;
$rpt_obj->RecordSelectionFormula = "{F_DOCLIGNE.DO_Piece}='{$id}'";
$rpt_obj->ExportOptions->DiskFileName = $file;
$rpt_obj->ExportOptions->PDFExportAllPages = true;
$rpt_obj->ExportOptions->DestinationType = 1;
$rpt_obj->ExportOptions->FormatType = 31;
$rpt_obj->Export(false);
header("Content-Type: application/pdf");
readfile($file);
示例3: COM
<?php
//set_time_limit(0);
ob_start();
$id = 12345;
$filename = "12345.pdf";
$params = 2015.0;
$params2 = 12;
$path = "D:\\MYrep";
//$file = $chemin."\\bill_".$id.".pdf";
$file = $path . "\\" . $id . ".pdf";
$app_obj = new COM("CrystalRuntime.Application") or die("Did not open");
$report = $path . "\\1234.rpt";
$rpt_obj = $app_obj->OpenReport($report, 1);
$app_obj->LogOnServer("p2ssql.dll", "localhost", "st_data", "sa", "Tamakogi2012");
$rpt_obj->EnableParameterPrompting = FALSE;
$rpt_obj->RecordSelectionFormula = "{rptinvoicesummarybysale.Year} = {$params} ";
$rpt_obj->ExportOptions->DiskFileName = $file;
$rpt_obj->ExportOptions->PDFExportAllPages = true;
$rpt_obj->ExportOptions->DestinationType = 1;
$rpt_obj->ExportOptions->FormatType = 31;
$rpt_obj->Export(false);
//header("location: http://localhost:81/yii2-st/backend/web/index.php?r=openreport/viewpdf");
header('Content-Type: application/pdf');
//header('Content-Disposition: attachment; filename="'.$filename2.'"');
readfile($file);