I think I've read many topics on that question but still get a wrong result.
I have a query parameters array that I want to loop with foreach()
to bind parameters.
foreach($aQueryParams as $key => &$value){
$stmt->bindParam($key, $value);
}
This concerns an INSERT
query and what I get as a result is the key inserted in my table instead of the value. But I'm sure that the key and the value are good and at the good place. A var_dump()
on $key
and $value
give :firstName
for the $key
and Samy
for the &$value
. But this is :firstName
that is inserted in my table...
And I also tried with a bindValue
without using the reference and it's the same result.
To be clearer, I give you the link of the gitHub repository. You can see the declaration of the parameters array in ClientManager.class.php at line 44, and the foreach() loop to bind parameters in DBOperation.class.php at line 97. https://github.com/code-climber/car_rental/blob/preparedStmt/src/car_rental/model/dao/ClientManager.class.php
I'm going mad with this.