Reputation: 447
Is it possible to show a SQL string coded in PDO with prepared params like this ? :
$nom_client = $dbh->prepare("SELECT client.IdClient,Nom_societe FROM client
LEFT JOIN intermediaire_has_client ON IdClient=intermediaire_has_client.Client_IdClient
WHERE intermediaire_has_client.Intermediaire_IdIntermediaire=:id_inter");
$nom_client->bindValue(":id_inter",$_SESSION['num_agence'],PDO::PARAM_INT);
$nom_client->execute();
Thanks in advance.
Upvotes: 0
Views: 82
Reputation: 71384
If you are asking to see the final "query" with all parameters in it, then you are not going to be able to get what you are after from within your PHP code.
The way prepared statements work is that the based query with parameter placeholders is sent to MySQL and "prepared". Follow on calls to MySQL just pass the parameters themselves. As such the full query with parameters in it never exists.
Your best best is to log in your MySQL query log (you might have to configure MySQL to log all queries), where you will be able to see the final interpreted representation of the query.
Upvotes: 2
Reputation: 522210
The SQL string is not being "coded". Placeholders are not copy-and-paste inserts. The query and the values really are sent as two separate parts to the database. The database sees the same "placeholder query" and gets the values separately.
Upvotes: 1