KoolReport's Forum

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

Error when using Left Join #262

Closed Tyler Neal opened this topic on on Apr 26, 2018 - 1 comments

Tyler Neal commented on Apr 26, 2018

Hello,

Getting the following error displayed on the page when attempting to display a field gotten from a left join, any ideas?

Displayed Error:

Warning: array_merge(): Argument #1 is not an array in /srv/users/serverpilot/apps/mobility-exchange/public/test_portal/vendor/koolphp/koolreport/koolreport/widgets/koolphp/Table.php on line 220

Class File

class ApprovedDevices extends \koolreport\KoolReport
{
    public function settings()
    {
        return array(
            "dataSources"=>array(
                "ApprovedDevices"=>array(
                    "connectionString"=>"mysql:host=" . DB_HOST . ";dbname=" . DB_NAME,
                    "username"=>DB_USER,
                    "password"=>DB_PASS,
                    "charset"=>"utf8"
                )
            )
        );
    }

    public function setup()
    {
        $this->src('ApprovedDevices')->query(MYSQL::type(
        DB::table('order_line_item')
            ->join('mco', 'order_line_item.mco_id', '=', 'mco.id')
            ->join('providers', 'order_line_item.provider_id', '=', 'providers.id')
            ->leftJoin('users', 'order_line_item.action_taken_by', '=', 'users.id')
            ->select('mco.name')->alias('mco_name')
            ->select('providers.name')->alias('provider_name')
            ->select('order_line_item.caregiver')
            ->select('order_line_item.member_id')
            ->select('order_line_item.tablet_id')
            ->select('order_line_item.phone_number')
            ->select('order_line_item.device_id')
            ->select('order_line_item.sim_id')
            ->select('order_line_item.shipping_address')
            ->select('order_line_item.tracking_number')
            ->select('order_line_item.ship_date')
            ->select('order_line_item.status')
            ->select('users.username')
            ->where('order_line_item.order_id', '=', $this->params["orderID"])
            ->where('order_line_item.approved', '=', 1)
        ))
            ->pipe($this->dataStore("ApprovedDevices"));
    }
}

View File:

use \koolreport\widgets\koolphp\Table;

Table::create(array(
    'dataStore'=>$this->dataStore('ApprovedDevices'),
        'columns'=>array(
            'mco_name'=>array(
                'label'=>'MCO'
            ),
            'provider_name'=>array(
                'label'=>'Provider'
            ),
            'caregiver'=>array(
                'label'=>'Caregiver'
            ),
            'member_id'=>array(
                'label'=>'Member ID'
            ),
            'tablet_id'=>array(
                'label'=>'Tablet ID'
            ),
            'phone_number'=>array(
                'label'=>'Phone #'
            ),
            'device_id'=>array(
                'label'=>'Device ID'
            ),
            'sim_id'=>array(
                'label'=>'SIM ID'
            ),
            'shipping_address'=>array(
                'label'=>'Shipping Address'
            ),
            'tracking_number'=>array(
                'label'=>'Tracking Number'
            ),
            'ship_date'=>array(
                'label'=>'Shipping Date'
            ),
            'status'=>array(
                'label'=>'Status'
            ),
            'username'=>array(
                'label'=>'Approved By'
            )
        ),
    'cssClass'=>array(
        'table'=>'table table-hover table-bordered'
    )
));
KoolReport commented on Apr 26, 2018

Hi Tyler,

Could you please try to change to debug mode. Instead of calling $report->run(); you call $report->debug();

There will show you all data of dataStore("ApprovedDevices"). Please notice the name of column if they are in this form order_line_item.status for example. I just suspected that the name of column you input into the Table is not correct name.

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

QueryBuilder