php - Multiple insert with prepared statement -
i want insert 5 llines in db, following
$qry = $db->prepare('insert ignore table (foo, bar) values (?,?), (?,?), (?,?), (?,?), (?,?)'); $qry->execute(array( array($foo1, $bar), array($foo2, $bar), array($foo3, $bar), array($foo4, $bar), array($foo5, $bar) ));
gives me error
warning: pdostatement::execute(): sqlstate[hy093]: invalid parameter number: number of bound variables not match number of tokens
what should make work ?
remove arrays in execute()
$qry = $db->prepare('insert ignore table (foo, bar) values (?,?), (?,?), (?,?), (?,?), (?,?)'); $qry->execute(array( $foo1, $bar, $foo2, $bar, $foo3, $bar, $foo4, $bar, $foo5, $bar ));
Comments
Post a Comment