Raw SQL not Working Phalcon 3.x

Got it smoothly working with phalcon 2.x but not working with phalcon 3.x

        $data = new BlanketItemTb();
        $sql = "SELECT iit.item_id, iit.item_description, format(bit.ordered_quantity,0) as ordered_quantity, format(bit.remaining_quantity,0) as remaining_quantity
                FROM blanket_item_tb bit
                LEFT JOIN item_inventory_tb iit ON bit.item_id = iit.item_id
                WHERE bit.blanket_id = '$blanket_id' ORDER BY iit.item_id";

     return new Resultset(
            null,
            $data,
            $data->getReadConnection()->query($sql)
        );

Dude, use parameter binding, right not it's not safe query beacause it can be sql injected. Also what you mean not working? Show us more info like what error etc.

>Dude, use parameter binding, right not it's not safe query beacause it can be sql injected. Also what you mean not working? Show us more info like what error etc.

Let's put aside first the binding, there's no particular error, however the returned result comes with full of nulls. As you can see here, phalcon 2 returns all data without null

Json Response Phalcon 2.X > [{"blanketid":"80","date":"2017-08-12","blanketno":"BL0000078","pono":"456456","customername":"PACIFIC PAINT","plantlocation":"Plant A - ","action":"Post","salesperson":"Andy Co"},{"blanketid":"79","date":"2017-08-12","blanketno":"BL0000077","pono":"123456","customername":"PACIFIC PAINT","plantlocation":"Plant A - ","action":"Post","salesperson":"Andy Co"}]

Json Reponse Phalcon 3.X > [{"blanketid":"80","blanketno":"BL0000078","date":"2017-08-12","pono":"456456","customerid":null,"plantid":null,"action":"Post","salesperson_id":null"}] >

But those are not fields you wrote you wrote in original post. Check in sql logs(add logger for queries if you don't have yet) what query is being made, then test it outside of phalcon if result is correct, if it's the same as phalcon - then it's not phalcon issue. If query is wrong then come back here.

edited Sep '17

>But those are not fields you wrote you wrote in original post. Check in sql logs(add logger for queries if you don't have yet) what query is being made, then test it outside of phalcon if result is correct, if it's the same as phalcon - then it's not phalcon issue. If query is wrong then come back here.

here's the query > $sql = "SELECT bmt.blanketid, bmt.date, bmt.blanketno, bmt.pono, ct.customername, CONCAT(cpt.plant, ' - ', cpt.city) as plantlocation, bmt.action, CONCAT(spt.firstname, ' ', spt.lastname) as salesperson > FROM blanketmaintb bmt > LEFT JOIN customertb ct ON bmt.customerid = ct.customerid
> LEFT JOIN customer
plantstb cpt ON bmt.plantid = cpt.plantid > LEFT JOIN salespersontb spt ON bmt.salespersonid = spt.salespersonid > LEFT JOIN blanketsotb bst ON bmt.blanketid = bst.blanketid > WHERE bst.blanketid IS NULL ORDER BY bmt.blanket_id DESC";

Anyone can help me with this one?