not_null not working with get()
Posted: Wed Dec 09, 2015 3:13 pm
Hi There,
I'm stuck while trying to check if row with specific value is present in a column or not.
However, code below works fine :
Laravel 4.2
Both these queries are run in Model file.
I wasted an hour to figure out what's going on.
Please guide.
I'm stuck while trying to check if row with specific value is present in a column or not.
Code: Select all
//$sample_group_name - is some value
$row=DB::connection('illumina')->table('sample_group')->where('sample_group_name',$sample_group_name)->get();
if(is_null($row)){
//doesn't work if rows are null
Log::info($row); //null
Log::info(" hahahah ");
$present=false;
}
else{
Log::info($row); //null
Log::info("bbabababa");
$present=true;
}
Code: Select all
$row=DB::connection('illumina')->table('sample_group')->where('sample_group_name',$sample_group_name)->first();
if(is_null($row)){
//works if rows are null
Log::info(" hahahah ");
$present=false;
}
else{
Log::info("bbabababa");
$present=true;
}
Both these queries are run in Model file.
I wasted an hour to figure out what's going on.
Please guide.