jeudi 29 septembre 2016

Laravel whereRaw not returning anything

I have written my sqlquery in workbench first before actually moving it over to laravel code, and I can confirm this works. Here is my sql query written in workbench

SET @info = 'hello';

SELECT device_type_id 
FROM arecibo.device_type_mappings
WHERE @info LIKE concat('%', name , '%') COLLATE utf8_unicode_ci;

I want to now convert this to code but am having troubles as it is not returning anything back. I have googled around to see what I might be missing but to no avail I could not find anything. Here is my attempted code:

$deviceTypeId = DB::table('device_type_mappings')
        ->select('device_type_id')
        ->whereRaw('? LIKE concat(\'%\', name , \'%\') COLLATE utf8_unicode_ci;', [$sysInfo])
        ->get();

if possible I would like to use the model, but it was complaining that there was no select method exposed.

I am using laravel 5.3



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2dnOHgj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire