Get the actual SQL prepared statement using mysqli?

Is there a way to get the actual SQL that results from preparing the statement when using the mysqli extension?

My problem: I use prepared statements. In all cases, they MUST update the record. I'm not wrong. However, when I check the affected lines, they are not. So, I want to see the actual SQL that will be executed as a result of the prepare statement.

Is there any way to do this? I am checking mysqli reference documents, but they have nothing.

+4
source share
2 answers

See this question for an answer to the question.

+1
source

While I was looking for a specific Mysqli answer, did I find that everyone refers only to PDO, thereby not addressing the problem with ? placeholder.

So, here I am publishing my contribution of a simple function to replace all parameters ? for parameters. (Php 7)

 function addParamsToSQL ( string $SQL, array $params ) : string { foreach($params as $value) $SQL = preg_replace ( '[\?]' , "'" . $value . "'" , $SQL, 1 ); return $SQL; } 
0
source

All Articles