<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/mysql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'mysqlinfo.library.choosing.php',
    1 => 'Choisir une biblioth&egrave;que',
    2 => 'Choisir une biblioth&egrave;que',
  ),
  'up' => 
  array (
    0 => 'mysql.php',
    1 => 'Aper&ccedil;u des drivers PHP MySQL',
  ),
  'prev' => 
  array (
    0 => 'mysqlinfo.api.choosing.php',
    1 => 'Choisir une API',
  ),
  'next' => 
  array (
    0 => 'mysqlinfo.concepts.php',
    1 => 'Concepts',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/mysqlinfo/set.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mysqlinfo.library.choosing" class="chapter">
   <h1 class="title">Choisir une bibliothèque</h1>

   <p class="simpara">
    Les extensions PHP mysqli et PDO_MySQL sont des enveloppes légères d&#039;une
    bibliothèque cliente C. Les extensions peuvent soit utiliser la bibliothèque
    <a href="book.mysqlnd.php" class="link">mysqlnd</a>, soit la bibliothèque <code class="literal">libmysqlclient</code>.
    Le choix de la bibliothèque se fait au moment de la compilation.
   </p>
   <p class="simpara">
    La bibliothèque mysqlnd fait partie de la distribution de PHP.
    Elle offre des fonctionnalités comme les connexions paresseuses,
    la mise en cache de requêtes, qui ne sont pas disponibles avec libmysqlclient,
    aussi, il est recommandé d&#039;utiliser la bibliothèque interne mysqlnd.
    Voir la <a href="book.mysqlnd.php" class="link">documentation de mysqlnd</a>
    pour plus d&#039;informations, ainsi qu&#039;une liste des fonctionnalités qu&#039;elle offre.
   </p>
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Commande de configuration pour l&#039;utilisation de mysqlnd ou de libmysqlclient</strong></p>
    <div class="example-contents">
<div class="shellcode"><pre class="shellcode">// Recommandé, compilation avec mysqlnd
$ ./configure --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd

// Alternativement recommandé, compilation avec mysqlnd
$ ./configure --with-mysqli --with-pdo-mysql

// Non recommandé, compilation avec libmysqlclient
$ ./configure --with-mysqli=/path/to/mysql_config --with-pdo-mysql=/path/to/mysql_config</pre>
</div>
    </div>

   </div>
   <div class="example" id="example-2">
    <p><strong>Exemple #2 Comparaison des instructions préparées</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// mysqli<br /></span><span style="color: #0000BB">$mysqli </span><span style="color: #007700">= new </span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"example.com"</span><span style="color: #007700">, </span><span style="color: #DD0000">"utilisateur"</span><span style="color: #007700">, </span><span style="color: #DD0000">"motdepasse"</span><span style="color: #007700">, </span><span style="color: #DD0000">"base de données"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$statement </span><span style="color: #007700">= </span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT District FROM City WHERE Name=?"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$statement</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">([</span><span style="color: #DD0000">"Amersfoort"</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">$statement</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get_result</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">$result</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fetch_assoc</span><span style="color: #007700">();<br />echo </span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'District'</span><span style="color: #007700">]);<br /><br /></span><span style="color: #FF8000">// PDO<br /></span><span style="color: #0000BB">$pdo </span><span style="color: #007700">= new </span><span style="color: #0000BB">PDO</span><span style="color: #007700">(</span><span style="color: #DD0000">'mysql:host=example.com;dbname=base de données'</span><span style="color: #007700">, </span><span style="color: #DD0000">'utilisateur'</span><span style="color: #007700">, </span><span style="color: #DD0000">'motdepasse'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$statement </span><span style="color: #007700">= </span><span style="color: #0000BB">$pdo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT District FROM City WHERE Name=?"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$statement</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">([</span><span style="color: #DD0000">"Amersfoort"</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">$statement</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fetch</span><span style="color: #007700">(</span><span style="color: #0000BB">PDO</span><span style="color: #007700">::</span><span style="color: #0000BB">FETCH_ASSOC</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'District'</span><span style="color: #007700">]);</span></span></code></div>
    </div>

   </div>
   <p class="simpara">
    <strong>Comparaison des fonctionnalités des bibliothèques</strong>
   </p>
   <p class="simpara">
    Il est recommandé d&#039;utiliser la bibliothèque <a href="book.mysqlnd.php" class="link">mysqlnd</a>
    au lieu de la bibliothèque client serveur MySQL (libmysqlclient). Les deux bibliothèques
    sont supportées et améliorées en permanence.
   </p>
   <table id="mysqlinfo.library.choosing.changelog" class="doctable informaltable">
    
     <thead>
      <tr>
       <th class="empty">&nbsp;</th>
       <th>Driver natif MySQL (<a href="book.mysqlnd.php" class="link">mysqlnd</a>)</th>
       <th>Bibliothèque client serveur MySQL (<code class="literal">libmysqlclient</code>)</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>Fait partie de la distribution de PHP</td>
       <td>Oui</td>
       <td>Non</td>
      </tr>

      <tr>
       <td>Introduit en version de PHP</td>
       <td>5.3.0</td>
       <td>N/A</td>
      </tr>

      <tr>
       <td>Licence</td>
       <td>PHP Licence 3.01</td>
       <td>Double-licence</td>
      </tr>

      <tr>
       <td>Statut de développement</td>
       <td>Actif</td>
       <td>Actif</td>
      </tr>

      <tr>
       <td>Cycle de vie</td>
       <td>Pas de fin annoncée</td>
       <td>Pas de fin annoncée</td>
      </tr>

      <tr>
       <td>Compilé par défaut (pour toutes les extensions MySQL)</td>
       <td>Oui</td>
       <td>Non</td>
      </tr>

      <tr>
       <td>Support du protocole de compression</td>
       <td>Oui</td>
       <td>Oui</td>
      </tr>

      <tr>
       <td>Support de SSL</td>
       <td>Oui</td>
       <td>Oui</td>
      </tr>

      <tr>
       <td>Support des pipes nommés</td>
       <td>Oui</td>
       <td>Oui</td>
      </tr>

      <tr>
       <td>Requêtes non bloquantes, asynchrones</td>
       <td>Oui</td>
       <td>Non</td>
      </tr>

      <tr>
       <td>Statistiques sur les performances</td>
       <td>Oui</td>
       <td>Non</td>
      </tr>

      <tr>
       <td>LOAD LOCAL INFILE respecte la <a href="ini.core.php#ini.open-basedir" class="link">directive open_basedir</a></td>
       <td>Oui</td>
       <td>Non</td>
      </tr>

      <tr>
       <td>Utilisation du système de gestion de la mémoire native de PHP
        (c.-à-d., suit les limites mémoires de PHP)</td>
       <td>Oui</td>
       <td>Non</td>
      </tr>

      <tr>
       <td>Retourne les colonnes numériques sous la forme de double (COM_QUERY)</td>
       <td>Oui</td>
       <td>Non</td>
      </tr>

      <tr>
       <td>Retourne les colonnes numériques sous la forme de chaînes de caractères (COM_QUERY)</td>
       <td>Oui</td>
       <td>Oui</td>
      </tr>

      <tr>
       <td>API du plugin</td>
       <td>Oui</td>
       <td>Limité</td>
      </tr>

      <tr>
       <td>Reconnexion automatique</td>
       <td>Non</td>
       <td>Optionnel</td>
      </tr>

     </tbody>
    
   </table>

  </div>
<?php manual_footer($setup); ?>