maxdb_warning_count

maxdb::warning_count

(PECL maxdb >= 1.0)

maxdb_warning_count -- maxdb::warning_countRetourne le nombre d'avertissements depuis la dernière requête pour un lien donné

Description

Style procédural

int maxdb_warning_count ( resource $link )

Style orienté objet

int $maxdb->warning_count;

maxdb_warning_count() retourne le nombre d'avertissements depuis la dernière requête dans la connexion représentée par le paramètre link.

Valeurs de retour

Nombre d'avertissements ou zéro s'il n'y en a aucun.

Exemples

Exemple #1 Style orienté objet

  1. <?php
  2. $maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB");
  3.  
  4. /* Vérification de la connexion */
  5. if (maxdb_connect_errno()) {
  6. printf("Echec de la connexion : %s\n", maxdb_connect_error());
  7. exit();
  8. }
  9.  
  10. $maxdb->query("CREATE TABLE temp.mycity LIKE hotel.city");
  11.  
  12. /* un nom de ville remarquablement long dans Wales */
  13. $query = "INSERT INTO temp.mycity (zip, name) VALUES('11111',
  14. 'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch')";
  15.  
  16. $maxdb->query($query);
  17.  
  18. printf ("Nombre d'avertissements : %d\n", $maxdb->warning_count);
  19.  
  20. /* Fermeture de la connexion */
  21. $maxdb->close();
  22. ?>

Exemple #2 Style procédural

  1. <?php
  2. $link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");
  3.  
  4. /* Vérification de la connexion */
  5. if (maxdb_connect_errno()) {
  6. printf("Echec de la connexion : %s\n", maxdb_connect_error());
  7. exit();
  8. }
  9.  
  10. maxdb_query($link, "CREATE TABLE temp.mycity LIKE hotel.city");
  11.  
  12. /* un nom de ville remarquablement long dans Wales */
  13. $query = "INSERT INTO temp.mycity (zip, name) VALUES('11111',
  14. 'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch')";
  15.  
  16. maxdb_query($link, $query);
  17.  
  18. printf ("Nombre d'avertissements : %d\n", maxdb_warning_count($link));
  19.  
  20. /* Fermeture de la connexion */
  21. maxdb_close($link);
  22. ?>

L'exemple ci-dessus va afficher quelque chose de similaire à :

Warning: maxdb_query(): -8004 POS(62) Constant must be compatible with column type and length <...>
 Nombre d'avertissements : 0

Voir aussi

  • maxdb_errno() - Retourne le code erreur pour le dernier appel à une fonction
  • maxdb_error() - Retourne une chaîne représentant la dernière erreur
  • maxdb_sqlstate() - Retourne l'erreur SQLSTATE depuis la dernière opération MaxDB

LoadingChargement en cours