I am trying to debug a SQL statement I have not written myself:
$stmt = $dbh->prepare("
SELECT
Customer.Primary_Email AS EMAIL,
...
FROM Order_SG
INNER JOIN Customer USING (Customer__)
INNER JOIN Order_SG_Detail USING (Order_SG__)
INNER JOIN Product_Ref USING (Product_Ref__)
INNER JOIN Reduction USING (Reduction__)
WHERE Order_SG.Server__ IN (:servers)
...
AND `DATE` BETWEEN :startDate AND :endDate
LIMIT :limit
OFFSET :offset");
$stmt->bindValue(':servers', implode(',', $servers));
$stmt->bindValue(':startDate', $startDate);
$stmt->bindValue(':endDate', $endDate);
$stmt->bindValue(':limit', $limit, \PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, \PDO::PARAM_INT);
How can I retrieve the statement after the binding? A string I could echo
is fine.