I have the php query below where I want to count how many times the id
exist in a column
$empCount = DB::table('m_employee')->count('group_id')->where('group_id',$idHolder);
VALUES
//tblname is m_employee; column name is group_id and my search variable is $idHolder
Error message is:
{"message":"Call to a member function where() on integer",.......
For this sample, when the value of my $idHolder
is 1, the result of $empCount
should be 13
, if it's 2, result is 3
.
And after that, how can I use AND
operator from this query :
DB::table('emp')->where('key', $emp)->update([
'id' => $id,
]);
Like where('key', $emp) AND ('monthyear', '06/2018')
, basing the date from the cost_date
column above (extracting only the month and year) .I'm having hard time on where to insert it.