I am trying to create a function that will build it’s own query with the PDO style.
The problem is that i need to create variable variable names.
I have a function insert_Query
public function insert_Query($data, $table){
The data is an assoc array and the table speaks for it self.
when in PDO style the query is ok the you can prepare it.
That is all good but than i need the binParam function to set the values from the array to variables.
Because the bindParam function does not like array’s it must be done with new variables.
Question how do i generate variables and there names and fill them with data.
I allready tried the following:
foreach($data as $k=>$v){
$k = 'var'.$i;
$$k = $v;
$i++;
}
And yeah it works and i get the variable names but how kun i bind them.
Because i still need the variables insite the bindParam function.
Is there a way with php to generate those lines of code?
If any questions let me know.
Why don’t you just pass an array to the
executemethod? Or usebindValue.or