KoolReport's Forum

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

Sql server connection #2008

Closed mustafa bulu opened this topic on on Apr 1 - 3 comments

mustafa bulu commented on Apr 1

I'm trying to connect to the sql server.I got an error like this:

Fatal error: Uncaught Error: Call to undefined function koolreport\datasources\sqlsrv_connect() in C:\xampp\htdocs\kool\vendor\koolreport\core\src\datasources\SQLSRVDataSource.php:117 Stack trace: #0 C:\xampp\htdocs\kool\vendor\koolreport\core\src\core\DataSource.php(57): koolreport\datasources\SQLSRVDataSource->onInit() #1 C:\xampp\htdocs\kool\vendor\koolreport\core\src\KoolReport.php(264): koolreport\core\DataSource->construct(Array, Object(SaleReport)) #2 C:\xampp\htdocs\kool\salereport\SaleReport.php(22): koolreport\KoolReport->src('sqlserver') #3 C:\xampp\htdocs\kool\vendor\koolreport\core\src\KoolReport.php(100): SaleReport->setup() #4 C:\xampp\htdocs\kool\salereport\index.php(7): koolreport\KoolReport->construct() #5 {main} thrown in C:\xampp\htdocs\kool\vendor\koolreport\core\src\datasources\SQLSRVDataSource.php on line 117

index.php

<?php

require_once "../vendor/autoload.php";

require_once "SaleReport.php";

$report= new SaleReport;

$report->run()->render();

SaleReport.php


<?php

class SaleReport extends \koolreport\Koolreport
{
    public function settings()
    {
        $pathh = '\koolreport\datasources\SQLSRVDataSource';
        return array(
            "dataSources"=>array(
                "sqlserver"=>array(
                    'host' => '127.0.0.1',
                    'username' => 'sa',
                    'password' => '---',
                    'dbname' => 'NORTHWND', 
                    'class' => $pathh
                ),
            )
        );
    }
    public function setup()
    {
        $this->src('sqlserver')
        ->query("
        SELECT Products.ProductName, Products.UnitPrice FROM Products WHERE UnitPrice > 100;
        ")
        ->pipe($this->dataStore('result'));
    }
}


SaleReport.view.php

<html>
    <head>
        <title>...</title>
    </head>
    <body>
    <?php
    \koolreport\widgets\koolphp\Table::create(array(
        "dataSource"=>$this->dataStore("result")
    ));
    ?>
    </body>
</html>
mustafa bulu commented on Apr 2

Please could anyone can help me?

KoolReport commented on Apr 2

Hi Mustafa,

Here is the example

Let us know if you need further assistance.

mustafa bulu commented on Apr 2

Thank you for your interest. I have successfully connected to sql server

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
solved

None