DEV Community

loading...

How I can avoid using `array_map` on my results returning primary keys in Laravel's 5.7 database layer?

pcmagas profile image Dimitrios Desyllas ・1 min read

I have the following table named mytable:

id SERIAL PK
namae VARCHAR

And using laravel 5.7 I need to retrieve the data using the following code (tested in a tinker session):

$yakuzaNames = DB::select('SELECT id from mytable where name like 'omaewa%')
dump($yakuzaNames);

The problem is that once data retrieved…

Discussion

pic
Editor guide