PHP Velho Oeste 2024

mysqli_stmt::__construct

(PHP 5, PHP 7, PHP 8)

mysqli_stmt::__constructConstruit un nouvel objet mysqli_stmt

Description

public mysqli_stmt::__construct(mysqli $mysql, ?string $query = null)

Cette méthode construit un nouvel objet mysqli_stmt.

Liste de paramètres

link

Un objet mysqli valide.

query

La requête, sous la forme d'une chaîne de caractères. Si ce paramètre est null, alors le constructeur se comporte comme la fonction mysqli_stmt_init() ; sinon il se comportera comme la fonction mysqli_prepare().

Erreurs / Exceptions

Si le rapport d'erreurs mysqli est activé (MYSQLI_REPORT_ERROR) et que l'opération demandée échoue, un avertissement est généré. Si, en plus, le mode est défini sur MYSQLI_REPORT_STRICT, une mysqli_sql_exception est lancée à la place.

Historique

Version Description
8.0.0 query est désormais nullable.

Voir aussi

add a note add a note

User Contributed Notes 1 note

up
0
tiomno at gmail dot com
7 years ago
There may be the case when you want/need to extend the `mysqli_stmt` class to add or overwrite some behaviour. In my case, I'm overwriting the `mysqli::prepare()` method to return an instance of my own class extended from `mysqli_stmt` to change its behaviour in some integration tests.

So please, do not remove or block the ability to use mysqli::__constructor(). Thanks!!
To Top