MySQLi
L'extension MySQLi (abréviation pour MySQL Improved en anglais, c'est-à-dire MySQL Amélioré) est un pilote informatique qui permet d'interfacer des programm…
L'extension MySQLi (abréviation pour MySQL Improved en anglais, c'est-à-dire MySQL Amélioré) est un pilote informatique qui permet d'interfacer des programmes écrits dans le langage de programmation PHP avec les bases de données MySQL, depuis la version 4.1[1].
Comparatif
Elle fait partie des trois API de connexion à MySQL :
- Extension PHP MySQL
- Extension PHP MySQLi
- PHP Data Objects (PDO)
| MySQLi | PDO | PHP's MySQL Extension | |
|---|---|---|---|
| Version de PHP | > 5.0 | > 5.0 | < 3.0 |
| Inclut avec PHP 5.x | |||
| Statut | Actif | Actif | Maintenance seulement |
| API avec codage des caractères | |||
| API avec instruction côté serveur | |||
| API avec instruction côté client | |||
| API avec procédure stockée | |||
| API avec instructions multiples | La plupart | ||
| Supporte toutes les fonctionnalités MySQL 4.1+ | La plupart |
Exemples
L'extension peut être utilisée soit par ses fonctions, soit par une classe et ses méthodes :
<?php
// Fonctions
$db = mysqli_connect("exemple.com", "utilisateur", "mot_de_passe");
mysqli_select_db($db, "MaBase"); // Le $link (ici $db), se place toujours en première position et est obligatoire avec MySQLI
$res = mysqli_query($db, "SELECT * FROM MaTable");
$ligne = mysqli_fetch_assoc($res);
var_dump($ligne);
// ou alors
while($row = mysqli_fetch_assoc($res)) {
$first = $row['COL_FIRST']
...
}
// Idem avec la classe
$mysqli = new mysqli("exemple.com", "utilisateur", "mot_de_passe", "MaBase");
$res = $mysqli->query("SELECT * FROM MaTable");
$ligne = $res->fetch_assoc();
var_dump($ligne);
?>
Références
- ↑ « Introduction », sur php.net (consulté le ).
Voir aussi
Liens externes
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.