I am in new in Laravel. I want to make dynamic where queries with laravel query builder.
Normally I can make dynamic queries in php
$where = array(
'hello' => 'world'
);
function get($where = null){
if($where == "") $where = "";
//Function which converts where clause into queries
wheretoqueries($where); //converts where clause
$sql = "SELECT * FROM $tbl $where";
return $sql;
}
echo get($where);
If where clause is null queries will be
SELECT * FROM $tbl
If where clause is not null queries will be
SELECT * FROM $tbl WHERE hello = "world"
Laravel orm works fine for where clause if key and value exists
A::where($where)->get();
If where is null following method will not work
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire