Nice innovation in the mysqli and in PHP 8.2: mysqli execute_query
In continuation of my previous article , I want to write about another nice innovation in themysqli
module.
Since PHP 8.2.0 there is a new functionmysqli_execute_query
ormysqli::execute_query
if you prefer object-oriented style.
This is a really nice feature. It allows you to kill two (three) birds with one stone:
Let's try this in practice:
<?php
$query = 'SELECT Name FROM City WHERE District=? ORDER BY Name LIMIT 5';
/* here the magic */
$result = $mysqli->execute_query($query, ['Nordrhein-Westfalen']);
foreach ($result as $row) {
printf("%s \n", $row["Name"]);
}
You can try this code here: phpize.online