KoolReport's Forum

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

Query Builder custom field #1105

Open Jérôme Schneider opened this topic on on Sep 27, 2019 - 4 comments

J
Jérôme Schneider commented on Sep 27, 2019

Hi, I'm trying to create a query where my field isn't a database field but a custom name that i want but the query result isn't what I expected.

$this->src("mysql")
        ->query(
            MySQL::type(
                DB::table('v_report_all')
                    ->select('"Divers"')->alias('Assocation')
                    ->sum('REC_NbPersTot')->alias('Effectif')
                    ->count('REC_NoSocieteDetails')->alias('NbEntreprise')
                    ->where('NoPeriode', '=', $noPeriode1)
                    ->where('ASS_BAffilieCP', '=', 0)
            )
        )
        ->pipe($this->dataStore("association_eff_ent_no_cp_1"));
SQLSTATE[42S22]: Column not found: 1054 Unknown column '"Divers"' in 'field list'

The problem is that i don't understand how to remove the ` character in the query. Is there a way to do that ?

K
KoolReport commented on Sep 27, 2019

If you do not like query to be added with quote for table name and column name as we do, please do this:

Go to the file \querybuilder\MySQL.php and put following content:

<?php

namespace koolreport\querybuilder;

class MySQL extends SQL
{
    protected $indentifierCover=array("","");//For table name and column name
}

In next version, QueryBuilder will not add quotes automatically so mostly your issue will be solved in next version. We are preparing to release new version of KoolReport.

J
Jérôme Schneider commented on Sep 27, 2019

I've changed that but now i have this error

Undefined index: Association (View: C:\Dev\xampp\htdocs\CPIH\laravel-cpih\resources\views\CPIH.blade.php)

It doesn't find my alias name

J
Jérôme Schneider commented on Sep 27, 2019

Sorry, it's my mistake I wrote Assocation in my query instead of Association...

Thanks

K
KoolReport commented on Sep 27, 2019

So is everything working now?

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
None yet

None