Home > other >  Is it possible to go through the content of ? in laravel query builder?
Is it possible to go through the content of ? in laravel query builder?

Time:07-01

There is an array. I put in where in Laravel query.

I would like to examine the contents of SQL.

$listArray = [1, 2, 3];
Stack::where('a_certain_column', $listArray)->toSql();

But the toSql() show:

where (a_certain_column = ?)

I just wanted to check the Array put in <?> properly.

CodePudding user response:

is it whereIn ?

Stack::whereIn('a_certain_column',$listArray); since its you search for array

CodePudding user response:

Please use this package it will give you the dynamic generated query result:

https://github.com/barryvdh/laravel-debugbar

Steps :

  1. composer require barryvdh/laravel-debugbar --dev

  2. add the ServiceProvider to the providers array in config/app.php

    Barryvdh\Debugbar\ServiceProvider::class,

  3. Add this under facades array in config/app.php

    'Debugbar' => Barryvdh\Debugbar\Facades\Debugbar::class,

CodePudding user response:

in your case it has to be whereIn Statment. So the code will look like:

$listArray = [1, 2, 3];
Stack::query()->whereIn('a_certain_column', $listArray)->toSql(); // or dd() instead of toSql()
  • Related