QueryBuilder

The example show how QueryBuilder will help you to build fast, error-free SQL statement

employeeNumberfirstNamelastNamejobTitle
1,002 Diane Murphy President
1,056 Mary Patterson VP Sales
1,076 Jeff Firrelli VP Marketing
1,088 William Patterson Sales Manager (APAC)
1,102 Gerard Bondur Sale Manager (EMEA)
1,143 Anthony Bow Sales Manager (NA)
1,165 Leslie Jennings Sales Rep
1,166 Leslie Thompson Sales Rep
1,188 Julie Firrelli Sales Rep
1,216 Steve Patterson Sales Rep
1,286 Foon Yue Tseng Sales Rep
1,323 George Vanauf Sales Rep
1,337 Loui Bondur Sales Rep
1,370 Gerard Hernandez Sales Rep
1,401 Pamela Castillo Sales Rep
1,501 Larry Bott Sales Rep
1,504 Barry Jones Sales Rep
1,611 Andy Fixter Sales Rep
1,612 Peter Marsh Sales Rep
1,619 Tom King Sales Rep
1,621 Mami Nishi Sales Rep
1,625 Yoshimi Kato Sales Rep
1,702 Martin Gerard Sales Rep

This example shows you to get started with QueryBuilder to generate error-free SQL using fluent PHP language. Please don't limit the usage of QueryBuilder inside KoolReport, QueryBuilder can be used standalone in any of your PHP application to generate SQL Query.

<?php

echo DB::table("employees")
    ->select('employeeNumber','firstName','lastName','jobTitle');

It will print

SELECT `employeeNumber`,`firstName`,`lastName`,`jobTitle` from employees
<?php
require_once "MyReport.php";

$report = new MyReport;
$report->run()->render();
<?php
//Step 1: Load KoolReport
require_once "../../../load.koolreport.php";

use \koolreport\querybuilder\DB;

//Step 2: Creating Report class
class MyReport extends \koolreport\KoolReport
{
    public function settings()
    {
        //Get default connection from config.php
        $config = include "../../../config.php";

        return array(
            "dataSources"=>array(
                "automaker"=>$config["automaker"]
            )
        );
    }   
    protected function setup()
    {
        $this->src('automaker')
        ->query(
            DB::table("employees")
            ->select('employeeNumber','firstName','lastName','jobTitle')
            ->toMySQL()
        )
        ->pipe($this->dataStore("employees"));
    } 

}
<?php
    use \koolreport\widgets\koolphp\Table;
?>
<div class="report-content">
    <div class="text-center">
        <h1>QueryBuilder</h1>
        <p class="lead">
            The example show how QueryBuilder will help you to build fast, error-free SQL statement
        </p>
    </div>
    <?php
    Table::create(array(
        "dataSource"=>$this->dataStore("employees"),
        "paging"=>true
    ));
    ?>
</div>

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport Get KoolReport Pro