MysqlndUhConnection::getErrorNumber
(PECL mysqlnd-uh >= 1.0.0-alpha)
MysqlndUhConnection::getErrorNumber — Returns the error code for the most recent function call
説明
public MysqlndUhConnection::getErrorNumber
( mysqlnd_connection $connection
) : int
Returns the error code for the most recent function call.
パラメータ
connection
- Mysqlnd connection handle. Do not modify!
返り値
Error code for the most recent function call.
例
MysqlndUhConnection::getErrorNumber() is not only executed after the invocation of a user space API call which maps directly to it but also called internally.
例1 MysqlndUhConnection::getErrorNumber() example
<?phpclass proxy extends MysqlndUhConnection { public function getErrorNumber($res) { printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true)); $ret = parent::getErrorNumber($res); printf("%s returns %s\n", __METHOD__, var_export($ret, true)); return $ret; }}mysqlnd_uh_set_connection_proxy(new proxy());printf("connect...\n");$mysqli = new mysqli("localhost", "root", "", "test");printf("query...\n");$mysqli->query("PLEASE_LET_THIS_BE_INVALID_SQL");printf("errno...\n");var_dump($mysqli->errno);printf("close...\n");$mysqli->close();?>
上の例の出力は以下となります。
connect... proxy::getErrorNumber(array ( 0 => NULL, )) proxy::getErrorNumber returns 0 query... errno... proxy::getErrorNumber(array ( 0 => NULL, )) proxy::getErrorNumber returns 1064 int(1064) close...
参考
- mysqlnd_uh_set_connection_proxy() - Installs a proxy for mysqlnd connections
- MysqlndUhConnection::getErrorString() - Returns a string description of the last error
- mysqli_errno() - 直近の関数コールによるエラーコードを返す
- mysql_errno() - 直近の MySQL 処理からエラーメッセージのエラー番号を返す