I'm using a software that use PDO to do request. The database requests are like this :
$query = "SELECT * FROM res_attachments WHERE res_id = ? AND status = ?";
$data = array('152', 'DEL');
The question I have is, how can I get the whole request with the "?" replace by $data elements ? I get this infos ($query and $data) after the query, I just have to "merge" it. I have to make a dynamic things, to works with a request with 2 arg or 10 args.
The result I want have to looks like :
"SELECT * FROM res_attachments WHERE res_id = '152' AND status = 'DEL'"
Solution
For those who have a similar issue, here is the solution I make :
$query = "SELECT * FROM res_attachments WHERE res_id = ? AND status = ?";
$data = array('152', 'DEL');
$tab = explode("?",$query);
for($i =0; $i < count($tab); $i++){
$Request .= $tab[$i] . "'" . $data[$i] . "'";
$finalRequest = str_replace('\'\'', '', $Request); // delete the double quote at the end
}
var_dump($finalRequest);