Tim
Tim

Reputation: 206

laravel 5.2 how to use the count query with where query

I have tried every where all examples I came across but still have the same problem error 'htmlentities() expects parameter 1 to be string, array given' I need to select count from the database and would like to use the raw select as i will have more flexibility on it but any point towards the right direction will be appreciated here is what i have been doing'

$totalOpen = DB::table('dam')
    ->select(array('dam.*', DB::raw('COUNT(dam.mivisjobid) as followers')))
    ->join('miviswf','miviswf.mivisid','=','dam.mivisjobid')
    ->whereRaw( 'miviswf.mivisid=dam.mivisjobid')
    ->whereIn('miviswf.Status', $inputIds) // pass an array
    ->orderBy('miviswf.datetimesubmitted', 'ASC');'

and i get this error 'htmlentities() expects parameter 1 to be string, object given (View: '

Upvotes: 0

Views: 802

Answers (2)

Tim
Tim

Reputation: 206

This worked fine

 DB::table(' dam')
      ->count(); 

Upvotes: 0

Arvind
Arvind

Reputation: 857

Try with this, don't use array inside the select method

->select('dam.*', DB::raw('COUNT(dam.mivisjobid) as followers'))

for reference: https://laravel.com/docs/5.2/queries#selects

Upvotes: 0

Related Questions