$this->select('name',
DB::raw("(
SELECT COUNT(id)
FROM test
WHERE mid = :member AND created > :from AND created < :to
) as numbers", [":member" => $member, ":from" => $from, ":to" => $to])
)
->where('id', '=', '5')
->groupBy('type');
My problem here is that I'm getting an error when I execute this command:
QueryException in Connection.php line 624:
SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters
Seems like that how I bind things are incorrent. Can anyone show me what am I missing here?
$this->select('name',
DB::raw("(
SELECT COUNT(id)
FROM test
WHERE mid = :member AND created > :from AND created < :to
) as numbers", ["member" => $member, "from" => $from, "to" => $to])
)
->where('id', '=', '5')
->groupBy('type');
Notice the array passed with values. It has to be without :
$Schedule = \DB::select(DB::raw("SELECT * FROM schedule where from_datetime <=:cd AND to_datetime >=:cd AND status = 1 AND id IN (SELECT MAX(id) FROM schedule WHERE is_deleted = 0 AND from_datetime <=:cd AND to_datetime >=:cd AND status = 1 GROUP BY display_serial,type ) ORDER BY id DESC"),['cd'=>$current_date]);
$this->selectRaw('name, (
SELECT COUNT(id)
FROM test
WHERE mid = ? AND created > ? AND created < ?
) as numbers', [$member, $from, $to])
)
->where('id', '=', '5')
->groupBy('type');