mercredi 24 août 2016

Laravel 5.2 select data unknown variable

my function in controller for get data when user search ajax

this is my code

$receiptNum = Request::get('receiptNum');
// echo $receiptNum = 123456
DB::connection()->enableQueryLog();
$q = DB::table('tbl_receipt AS r')
            ->join('company AS com', 'r.com_id', '=', 'com.com_id')
           ->join('branches AS b', 'com.b_id', '=', 'b.b_id')
            ->join('employee AS e', 'r.created_by', '=', 'e.e_id')
           ->where('r.receipt_code','=',$receiptNum)
            ->get();
        $query = DB::getQueryLog();
        var_dump($query);

I don't know what missing in my code, it's show raw sql like this

SELECT * FROM "tbl_receipt" AS "r" INNER JOIN "company" AS "com" ON "r"."com_id" = "com"."com_id" INNER JOIN "branches" AS "b" ON "com"."b_id" = "b"."b_id" INNER JOIN "employee" AS "e" ON "r"."created_by" = "r"."e_id" WHERE "r"."receipt_code" = ?

I trying to replace $receiptNum by num 123 for test, it's also show ? in raw sql, please help me to solve it.

Thanks !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire