現在の位置: ホーム> 関数カテゴリ一覧> mysqli::$error_list

mysqli::$error_list

(mysqli_error_list)実行された前のコマンドのエラーリストを返します
名前:mysqli::$error_list
カテゴリ:mysqli
対応言語:php
一言説明:最後の関数呼び出しのエラーのリストを返します。

定義と使用法

error_list / mysqli_error_list()関数は、最後に実行されたコマンドのエラーリスト(もしあれば)を返します。

例1-オブジェクト指向のスタイル

実行された最後のコマンドのエラーリスト(存在する場合)を返します。

 <?php
$ mysqli = new mysqli ( "localhost" 、 "my_user" 、 "my_password" 、 "my_db" ) ;

if ( $ mysqli- > connect_errno ) {
  エコー「MySQLに接続できなかった:」 。 $ mysqli- > connect_error ;
  出口( ) ;
}

//クエリを実行し、エラーを確認します
if ( ! $ mysqli- > query ( "persons(firstname)values( 'glenn')" ) ) {
  print_r ( $ mysqli- > error_list ) ;
}

$ mysqli- > close ( ) ;
?>

例2-手続きスタイル

実行された最後のコマンドのエラーリスト(存在する場合)を返します。

 <?php
$ con = mysqli_connect ( "localhost" 、 "my_user" 、 "my_password" 、 "my_db" ) ;

if ( mysqli_connect_errno ( ) ) {
  エコー「MySQLに接続できなかった:」 。 mysqli_connect_error ( ) ;
  出口( ) ;
}

//クエリを実行し、エラーを確認します
if ( ! mysqli_query ( $ con 、 "inserting into persons(firstname)values( 'glenn')" ) ) {
  print_r ( mysqli_error_list ( $ con ) ) ;
}

mysqli_close ( $ con ) ;
?>
類似の関数
人気記事(にんききじ)