Insert multiple rows with bindparam

552 Views Asked by At

Well , i´ve got a problem with bindparam insertion

$sql="INSERT INTO $tabla (value1,value2,value3)";

for($arrays as array){
  $sql.=",($array,:bind2,:bind3)"
}
$stmt=conection::conect()->prepare($sql);
$stmt->bindParam(:bind2, $data2);
$stmt->bindParam(:bind3, $data3);
$stmt->execute();

What i´m looking for is to build somethig like that

 INSERT INTO $table (value1, value2, value3) 
 
  VALUE (array[0],:bind2,:bind3),
        (array[1],:bind2,:bind3),
        (array[2],:bind2,:bind3)

, as you can see the first value is inserted throught a for loop and the others values (value2 and value 3) are the same bind baram, it means that only value1 will change when i do the insertion, but for some reason it only inserts the first value and it doesn´t execute all the query. I hope you can help me guys. (Sorry for my english)

0

There are 0 best solutions below