I'm converting a PHP PDO instance to Laravel 5.5. I changed the DB connection from/to:
//$dbc = new PDO ('mysql:host='. $DB_HOST .';dbname='. $DB_NAME, $DB_USER, $DB_PASS); $dbc = \Illuminate\Support\Facades\DB::connection('foobardb')->getPdo();
For some reason, this is causing my SELECT query to fail.
$query = "SELECT * FROM foobartable WHERE date_created > :sunday AND date_created <= :monday AND date_updated > :sunday AND date_updated <= :monday"; $stmt = $dbc->prepare($query); $stmt->bindValue(':monday', $monday, PDO::PARAM_STR); $stmt->bindValue(':sunday', $sunday, PDO::PARAM_STR); $stmt->execute(); $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
According to the stack trace, the error is specifically triggered on the
SQLSTATE[HY093]: Invalid parameter number
I obviously have the correct parameters, and this works just fine using PHP's PDO instance, so why does it not work with Laravel?