PHP 8.5.0 Beta 1 available for testing

Voting

: max(two, four)?
(Example: nine)

The Note You're Voting On

albright atat anre dotdot net
17 years ago
When passing an array of values to execute when your query contains question marks, note that the array must be keyed numerically from zero. If it is not, run array_values() on it to force the array to be re-keyed.

<?php
$anarray
= array(42 => "foo", 101 => "bar");
$statement = $dbo->prepare("SELECT * FROM table WHERE col1 = ? AND col2 = ?");

//This will not work
$statement->execute($anarray);

//Do this to make it work
$statement->execute(array_values($anarray));
?>

<< Back to user notes page

To Top