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…

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 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 :

MySQLi PDO PHP's MySQL Extension
Version de PHP > 5.0 > 5.0 < 3.0
Inclut avec PHP 5.x  Oui  Oui  Oui
Statut Actif Actif Maintenance seulement
API avec codage des caractères  Oui  Oui  Non
API avec instruction côté serveur  Oui  Oui  Non
API avec instruction côté client  Non  Oui  Non
API avec procédure stockée  Oui  Oui  Non
API avec instructions multiples  Oui La plupart  Non
Supporte toutes les fonctionnalités MySQL 4.1+  Oui La plupart  Non

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

  1. « Introduction », sur php.net (consulté le ).

Voir aussi

Sur les autres projets Wikimedia :

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.

  1. 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:
  2. 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.
  3. 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.
  4. 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.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.