I am a beginner, and currently creating a laravel project which needs multi-condition query like this:
Each of these three conditions could be blank.
If one is blank, the corresponding controller should not add 'where clause' when querying the db.
I know in java, I can apply if clause to this like:
String sql = "select field from table where 1 = 1";
if(a!=null&&!a.isEmpty())
sql+=" and a = '"+a+"'";
then execute sql......
but in laravel, how do i address this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire