PHPJasper / phpjasper

A PHP report generator
MIT License
463 stars 162 forks source link

PHPJasper not recognizing database settings #264

Closed dinhunzvi closed 3 years ago

dinhunzvi commented 3 years ago

@geekcom i have the PHP code below.

`<?php require_once './core/initialize.php';

use PHPJasper\PHPJasper;

$options = [
    'params'    => [
        '$P{invoice_id}'    => 11
    ],
    'format'    => [
        'pdf', 'rtf',
    ],
    'locale' => 'en',
    'db_connection' => [
        'driver' => 'mysql', //mysql, ....
        'username' => 'xxxx',
        'password' => xxxx'',
        'host' => 'localhost',
        'database' => 'xxxxx',
        'port' => '3306'
    ]
];

$input = REPORTS_DIR . 'debtors_aging_analysis.jrxml';

$jasper = new PHPJasper;

try {
    $output = __DIR__ . '/reports';

    $jasper->process(
        $input,
        $output,
        $options
    )->execute();
} catch ( Exception $e ) {
    echo $e->getMessage();
}`

the report is working fine in JasperStudio 6.15.0. when i try to view to view the report in PHP i'm getting this error.

usage: jasperstarter process [-h] -f <fmt> [<fmt> ...] [-o <output>] [-w] [-a [<filter>]] [-P <param> [<param> ...]] [-r [<resource>]] [-t <dstype>] [-H <dbhost>] [-u <dbuser>] [-p <dbpasswd>] [-n <dbname>] [--db-sid <sid>] [--db-port <port>] [--db-driver <name>] [--db-url <jdbcUrl>] [--jdbc-dir <dir>] [--data-file <file>] [--csv-first-row] [--csv-columns <list>] [--csv-record-del <delimiter>] [--csv-field-del <delimiter>] [--csv-charset <charset>] [--xml-xpath <xpath>] [--json-query <jsonquery>] [--jsonql-query <jsonqlquery>] [-N <printername>] [-d] [-s <reportname>] [-c <copies>] [--out-field-del <delimiter>] [--out-charset <charset>] <input> jasperstarter: error: argument -p: expected one argument

the strange thing is i can get PHPJasper to list the report's parameter. I am using PHP 7.4.7 and 10.4.13-MariaDB.

dinhunzvi commented 3 years ago

figures out that my password was the reason why the report could not retrieve database configuration settings from PHP. i'm not sure why but PHPJasper works alphanumeric passwords only.