PHP 8.5.0 Alpha 4 available for testing

Voting

: eight minus six?
(Example: nine)

The Note You're Voting On

Rami jamleh
12 years ago
simplified $placeholder form

<?php

$data
= ['a'=>'foo','b'=>'bar'];

$keys = array_keys($data);
$fields = '`'.implode('`, `',$keys).'`';

#here is my way
$placeholder = substr(str_repeat('?,',count($keys)),0,-1);

$pdo->prepare("INSERT INTO `baz`($fields) VALUES($placeholder)")->execute(array_values($data));

<< Back to user notes page

To Top