MysqlndUhConnection::getErrorNumber
MysqlndUhConnection::getFieldCount
MysqlndUhConnection
PHP Manual

# MysqlndUhConnection::getErrorString

(PECL mysqlnd-uh >= 1.0.0-alpha)

MysqlndUhConnection::getErrorString — Returns a string description of the last error

### 説明

public string MysqlndUhConnection::getErrorString ( mysqlnd_connection `$connection` )

Returns a string description of the last error.

### パラメータ

`connection`

  Mysqlnd connection handle. Do not modify!

### 返り値

Error string for the most recent function call.

### 例

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

例1 MysqlndUhConnection::getErrorString() example

`<?php
class proxy extends MysqlndUhConnection {
public function getErrorString($res) {
printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
$ret = parent::getErrorString($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("WILL_I_EVER_LEARN_SQL?");
printf("errno...\n");
var_dump($mysqli->error);
printf("close...\n");
$mysqli->close();
?>`

上の例の出力は以下となります。

    connect...
    proxy::getErrorString(array (
      0 => NULL,
    ))
    proxy::getErrorString returns ''
    query...
    errno...
    proxy::getErrorString(array (
      0 => NULL,
    ))
    proxy::getErrorString returns 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'WILL_I_EVER_LEARN_SQL?\' at line 1'
    string(168) "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WILL_I_EVER_LEARN_SQL?' at line 1"
    close...

### 参考

- mysqlnd_uh_set_connection_proxy() - Installs a proxy for mysqlnd connections
- MysqlndUhConnection::getErrorNumber() - Returns the error code for the most recent function call
- mysqli_error() - 直近のエラーの内容を文字列で返す
- mysql_error() - 直近に実行された MySQL 操作のエラーメッセージを返す

MysqlndUhConnection::getErrorNumber
MysqlndUhConnection::getFieldCount
MysqlndUhConnection
PHP Manual