I creating a wrapper function for Laravel Query Builder for creating dynamic query and not repeating same things. My function is given below
Class Crud{
public function get($tbl,$field,$where){
$query = Capsule::table($tbl);
if($where != null) $query = $query->where($where);
$query = $query->select($field);
return $query;
}
}
Function call
$crud = new Crud();
$field = ['a','b','c'];
$where = ['x' => 1];
$query = $crud->get('tbl',$field,$where);
Question:
Is this query slow down performence?
Why I see log like this?
Select * from tbl
Select * from tbl where (x = ?)
Select a,b,c from tbl where (x = ?)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire