Documentation Home
MySQL PHP API
Download this Manual
PDF (US Ltr) - 2.8Mb
PDF (A4) - 2.8Mb
EPUB - 456.4Kb
HTML Download (TGZ) - 395.8Kb
HTML Download (Zip) - 409.6Kb


MySQL PHP API  /  ...  /  MysqlndUhConnection::getErrorNumber

9.7.9 MysqlndUhConnection::getErrorNumber

Copyright 1997-2014 the PHP Documentation Group.

  • MysqlndUhConnection::getErrorNumber

    Returns the error code for the most recent function call

Description

public int MysqlndUhConnection::getErrorNumber(mysqlnd_connection connection);

Returns the error code for the most recent function call.

Parameters

connection

Mysqlnd connection handle. Do not modify!

Return Values

Error code for the most recent function call.

Examples

MysqlndUhConnection::getErrorNumber is not only executed after the invocation of a user space API call which maps directly to it but also called internally.

Example 9.16 MysqlndUhConnection::getErrorNumber example


<?php
class 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();
?>

    

The above example will output:


connect...
proxy::getErrorNumber(array (
  0 => NULL,
))
proxy::getErrorNumber returns 0
query...
errno...
proxy::getErrorNumber(array (
  0 => NULL,
))
proxy::getErrorNumber returns 1064
int(1064)
close...


See Also

mysqlnd_uh_set_connection_proxy
MysqlndUhConnection::getErrorString
mysqli_errno
mysql_errno


User Comments
Sign Up Login You must be logged in to post a comment.