©
이 문서에서는 PHP 중국어 웹사이트 매뉴얼 풀어 주다
(PHP 5)
mysqli::errno -- mysqli_errno — 返回最近函数调用的错误代码
面向对象风格
过程化风格
$link
)返回最近的mysqli函数调用产生的错误代码.
客户端错误在Mysqlerrmsg.h头文件中列出, 服务端错误好在mysqld_error.h中列出. 在mysql源码分发包中的Docs/mysqld_error.txt你可以发现一个完整的错误消息和错误号.
link
仅以过程化样式:由 mysqli_connect() 或 mysqli_init() 返回的链接标识。
最后一次调用产生的错误代码, 返回0代表没有错误发生.
Example #1 mysqli->errno example
面向对象风格
<?php
$mysqli = new mysqli ( "localhost" , "my_user" , "my_password" , "world" );
if ( mysqli_connect_errno ()) {
printf ( "Connect failed: %s\n" , mysqli_connect_error ());
exit();
}
if (! $mysqli -> query ( "SET a=1" )) {
printf ( "Errorcode: %d\n" , $mysqli -> errno );
}
$mysqli -> close ();
?>
过程化风格
<?php
$link = mysqli_connect ( "localhost" , "my_user" , "my_password" , "world" );
if ( mysqli_connect_errno ()) {
printf ( "Connect failed: %s\n" , mysqli_connect_error ());
exit();
}
if (! mysqli_query ( $link , "SET a=1" )) {
printf ( "Errorcode: %d\n" , mysqli_errno ( $link ));
}
mysqli_close ( $link );
?>
以上例程会输出:
Errorcode: 1193
[#1] erwin at transpontine dot com [2013-06-28 05:31:11]
You can also find the error codes for for example MySQL 5.5 here: http://dev.mysql.com/doc/refman/5.5/en/error-handling.html