KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

SQL Server Connection #3206

Open Adolfo Alonso opened this topic on on Dec 7, 2023 - 3 comments

Adolfo Alonso commented on Dec 7, 2023

Hi, Im trying to connect to a SLQ Server database, literally copy paste the documentation example and changed the connection paramenters and I get this error:

Fatal error: Uncaught Error: Class "koolreport\KoolReport" not found in C:\xampp\htdocs\reportes\liquidaciones\MyReport.php:3 Stack trace: #0 C:\xampp\htdocs\reportes\liquidaciones\index.php(2): require_once() #1 {main} thrown in C:\xampp\htdocs\reportes\liquidaciones\MyReport.php on line 3

Thanks

MyReport.php

<?php
	
class MyReport extends \koolreport\KoolReport
{
    public function settings()
    {
        return array(
            "dataSources"=>array(
                "sqlserver"=>array(
                    'host' => 'XXX',
                    'username' => 'XXX',
                    'password' => 'XXX',
                    'dbname' => 'XXX',
                    'charset' => 'utf8',  
                    'class' => "\koolreport\datasources\SQLSRVDataSource"  
                ),
            )
        );
    }
    public function setup()
    {
        $this->src('sqlserver')
        ->query("SELECT * FROM general_area")
        ->params(array(":status"=>"completed"))
        ->pipe($this->dataStore('purchase_summary'));
    }
} 
KoolReport commented on Dec 8, 2023

This error happens when the KoolReport library is not included. Please add the below path if you install koolreport manually.

require "/path/to/koolreport/core/autoload.php";

or if you install by composer, please include the path "vendor/autoload.php"

Let us know if you need further assistance.

Adolfo Alonso commented on Mar 1

Hello, I have added the require and still have the same problem.

MyReport.php

<?php
require_once "../../koolreport/core/autoload.php";
class MyReport extends \koolreport\KoolReport
{
    public function settings()
    {
        return array(
            "dataSources"=>array(
				"sqlserver"=>array(
				'host' => 'XXX',
				'username' => 'XXX',
				'password' => 'XXX',
				'dbname' => 'XXX',
				'charset' => 'utf8',  
				'class' => "\koolreport\datasources\SQLSRVDataSource",
				'returnDatesAsStrings'=>true  
			  ),
            )
        );
    }
    public function setup()
    {
        $this->src('sqlserver')
        ->query("SELECT * FROM general_area")
        ->params(array(":status"=>"completed"))
        ->pipe($this->dataStore('purchase_summary'));
    }
} 
Adolfo Alonso commented on Mar 1

I was able to solve it by installing SQL Server PHP drivers. Thanks

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None