In PHP with PDO, how to check the final SQL parametrized query?

In PHP with PDO, you can use the debugDumpParams() method on a prepared statement object to view the final SQL parametrized query. Here is an example:

<?php

$stmt = $pdo->prepare("SELECT * FROM users WHERE id = :id");
$stmt->bindValue(':id', $user_id);
$stmt->execute();
$stmt->debugDumpParams();

Watch a course Learn object oriented PHP

This will print the final SQL query with parameter values replaced in to the console.