mysqli_stmt::$param_count

mysqli_stmt_param_count

(PHP 5, PHP 7, PHP 8)

mysqli_stmt::$param_count -- mysqli_stmt_param_countRetourne le nombre de paramètres d'une commande SQL

Description

Style orienté objet

Style procédural

mysqli_stmt_param_count(mysqli_stmt$statement): int

Retourne le nombre de variables attendues par la commande préparée stmt.

Liste de paramètres

statement

Style procédural uniquement : Un objet mysqli_stmt retourné par la fonction mysqli_stmt_init().

Valeurs de retour

Retourne un entier représentant le nombre de paramètres.

Exemples

Exemple #1 Style orienté objet

<?php
$mysqli
= new mysqli("localhost", "my_user", "my_password", "world");


if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
exit();
}

if (
$stmt = $mysqli->prepare("SELECT Name FROM Country WHERE Name=? OR Code=?")) {

$marker = $stmt->param_count;
printf("La requête a %d variables.\n", $marker);


$stmt->close();
}


$mysqli->close();
?>

Exemple #2 Style procédural

<?php
$link
= mysqli_connect("localhost", "my_user", "my_password", "world");


if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
exit();
}

if (
$stmt = mysqli_prepare($link, "SELECT Name FROM Country WHERE Name=? OR Code=?")) {

$marker = mysqli_stmt_param_count($stmt);
printf("La requête a %d variables.\n", $marker);


mysqli_stmt_close($stmt);
}


mysqli_close($link);
?>

Les exemples ci-dessus vont afficher :

La requête a 2 variables.

Voir aussi

To Top