Skip to content

Error Connecting to database #8

@techkimchhay

Description

@techkimchhay

I am trying to connect to database but get an error like this

`C:\wamp64\www\smb-report\vendor\geekcom\phpjasper-laravel\src\PHPJasper.php
/**
* @param bool $user
* @return mixed
* @throws Exception\InvalidCommandExecutable
* @throws Exception\InvalidResourceDirectory
* @throws Exception\ErrorCommandExecutable
*/
public function execute($user = false)
{
$this->validateExecute();
$this->addUserToCommand($user);

    $output = [];
    $returnVar = 0;

    chdir($this->pathExecutable);
    exec($this->command, $output, $returnVar);
    if ($returnVar !== 0) {
        //throw new \PHPJasper\Exception\ErrorCommandExecutable();
        throw new \Exception("{$output[0]}", 1);
    }

    return $output;
}

/**
 * @return string
 */
public function output()
{
    return $this->command;
}

/**
 * @param $user
 */
protected function addUserToCommand($user)
{
    if ($user && !$this->windows) {
        $this->command = 'su -u ' . $user . " -c \"" . $this->command . "\"";

Arguments
"usage: jasperstarter process [-h] -f [ ...] [-o ] [-w]"`

and here is my config

` public function generate()
{
//$input = DIR . '/vendor/geekcom/phpjasper/examples/hello_world.jasper';
$input = base_path('/vendor/geekcom/phpjasper-laravel/examples/Database.jasper');
$output = base_path('/vendor/geekcom/phpjasper-laravel/examples');

    $options = [
        'format' => ['pdf'],
        'locale' => 'en',
        'db_connection' => [
            'driver' => 'mysql',
            'username' => 'root',
            'password' => '',
            'host' => '127.0.0.1',
            'database' => 'smb',
            'port' => '3306'
        ]
    ];

    $jasper = new PHPJasper;

    $jasper->process(
        $input,
        $output,
        $options
    )->execute();
    return view('welcome');
}`

could you please help to tell what's went wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions