-
Notifications
You must be signed in to change notification settings - Fork 45
/
databasesample.php
44 lines (37 loc) · 1.06 KB
/
databasesample.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
include "main.php";
use simitsdk\phpjasperxml\PHPJasperXML;
$filename = __DIR__.'/databasesample.jrxml';
$config = [
'driver'=>'array',
'data'=>[
['user_id'=>0, 'fullname' => 'name1','email'=>'email1@a.com','gender'=>'M' ],
['user_id'=>1, 'fullname' => 'name2','email'=>'email2@a.com','gender'=>'F' ],
['user_id'=>2, 'fullname' => 'name3','email'=>'email3@a.com','gender'=>'M' ],
]
];
// $config = [
// 'driver'=>'postgresql',
// 'host'=>'127.0.0.1',
// 'user'=>'postgres',
// 'pass'=>'postgres',
// 'name'=>'demo',
// ];
// $config = [
// 'driver'=>'mysql',
// 'host'=>'127.0.0.1',
// 'user'=>'root',
// 'pass'=>'root',
// 'name'=>'demo',
// ];
// $config = [
// 'driver'=>'pdo',
// 'dsn'=>'mysql:host=127.0.0.1;dbname=demo;',
// 'user'=>'root',
// 'pass'=>'root'
// ];
$report = new PHPJasperXML();
$report->load_xml_file($filename)
->setParameter(['reporttitle'=>'Database Report With Driver : '.$config['driver']])
->setDataSource($config)
->export('Pdf');