laravel return this error on execute this line:
$select = trim($request->select);
$where = trim($request->where);
$d = trim($request->d);
$order = trim(stripslashes($request->order));
$limit = isSet($request->limit) ? " LIMIT ".trim($request->limit) : '';
$forUser = trim(stripslashes($request->userId));
$campaignId = trim(stripslashes($request->campaignId));
$userRole = trim(stripslashes($request->userRole));
$events = DB::select('SELECT *, DATE_FORMAT(timestamp, ?) selector FROM events WHERE DATE_FORMAT(timestamp, ?) = ? AND campaignId = ? ORDER BY ? ASC ?', [$select, $where, $d, $campaignId, $order, $limit])->get();
Error:
[2018-05-21 19:09:22] local.ERROR: exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?' at line 1' in C:\xampp\htdocs\spotlike_laravel\trunk\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:77
Any ideas? :(
LIMITkeyword in your query when I look at your variables and the question marks in the query.ORDER BY 'some_field' ASC 'LIMIT 30'$events = DB::select('SELECT *, DATE_FORMAT(timestamp, ?) selector FROM events WHERE DATE_FORMAT(timestamp, ?) = ? AND campaignId = ? ORDER BY ? ASC ?', [$select, $where, $d, $campaignId, $order, $limit]); dd($event->toSql(), $event->getBindings());That willddthe query and the parameters that are passed. Might shed a little bit more light on the problem.