I want to show the amount of data stored on the database tables using Laravel v 4.2.0 but i have a problem with using function count(). here's my code :
$total = DB::select("select count(*) from rents left join operators on operators.code = rents.code where (operators.code is null) and rents.booking = 'N'");
echo $total;
the message error say :
Syntax error or access violation
can anyone help me?
Try this:
$total = DB::select(DB::raw("select count(*) as cnt from rents left join operators on operators.code = rents.code where (operators.code is null) and rents.booking = 'N'"));
echo $total[0]->cnt;
Try Debugging:
echo "<pre>";
print_r($total);
echo "</pre>";
exit;
See, if that helps.