Can you use query builder to build a query with a dynamic WHERE clause at runtime in laravel?

后端 未结 2 602
醉梦人生
醉梦人生 2021-01-25 02:16

So I know if I build a dynamic SQL string I can do something like the following

$SQL = \"SELECT * FROM \" . $table;

$first = 1;
foreach($items as $key => $va         


        
2条回答
  •  北海茫月
    2021-01-25 02:46

    foreach( $items as $key => $value )
    {
        $query->where( $key, '=', $value );
    }
    

    Is something like that what you're after?

    EDIT: Looks like Mark beat me to it.

提交回复
热议问题