MySQL PDO Name-Value Prepared Statement Using Last Parameter Only
问题 As titled, I'm using MySQL PDO with a prepared statement, and when executing, I'm getting a single value (the last supplied value) pushed into all fields. Table looks like so: id (int - auto-increment) a_id (int) b_id (int) INSERT looks like this: INSERT INTO my_table(a_id, b_id) VALUES (:a_id, :b_id) Code to insert looks like this... $stmt = $conn->prepare($sql); foreach($params as $k => $v) { $stmt->bindParam( $k, $v ); } $stmt->execute(); The statement successfully inserts a value (which