summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/mysqli/mysqli_api.c24
-rw-r--r--ext/mysqli/mysqli_fe.c2
-rw-r--r--ext/mysqli/mysqli_nonapi.c17
-rw-r--r--ext/mysqli/php_mysqli.h2
4 files changed, 34 insertions, 11 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index f5b6221be2..451bc4394e 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -1422,6 +1422,8 @@ PHP_FUNCTION(mysqli_real_connect)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", mysql_error(mysql));
RETURN_FALSE;
}
+ php_mysqli_set_error(mysql_errno(mysql), (char *)mysql_error(mysql) TSRMLS_CC);
+
RETURN_TRUE;
}
/* }}} */
@@ -1675,23 +1677,23 @@ PHP_FUNCTION(mysqli_stmt_close)
/* }}} */
/* {{{ proto void mysqli_stmt_data_seek(object stmt, int offset)
- Move internal result pointer */
+Move internal result pointer */
PHP_FUNCTION(mysqli_stmt_data_seek)
{
- STMT *stmt;
- zval *mysql_stmt;
- PR_STMT *prstmt;
- long offset;
+STMT *stmt;
+zval *mysql_stmt;
+PR_STMT *prstmt;
+long offset;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_stmt, mysqli_stmt_class_entry, &offset) == FAILURE) {
- return;
- }
+if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_stmt, mysqli_stmt_class_entry, &offset) == FAILURE) {
+ return;
+}
- MYSQLI_FETCH_RESOURCE(stmt, STMT *, prstmt, PR_STMT *, &mysql_stmt, "mysqli_stmt");
+MYSQLI_FETCH_RESOURCE(stmt, STMT *, prstmt, PR_STMT *, &mysql_stmt, "mysqli_stmt");
- mysql_stmt_data_seek(stmt->stmt, offset);
- return;
+mysql_stmt_data_seek(stmt->stmt, offset);
+return;
}
/* }}} */
diff --git a/ext/mysqli/mysqli_fe.c b/ext/mysqli/mysqli_fe.c
index 5e0389c8cb..6c6f50ee3b 100644
--- a/ext/mysqli/mysqli_fe.c
+++ b/ext/mysqli/mysqli_fe.c
@@ -50,6 +50,8 @@ function_entry mysqli_functions[] = {
PHP_FE(mysqli_close, NULL)
PHP_FE(mysqli_commit, NULL)
PHP_FE(mysqli_connect, NULL)
+ PHP_FE(mysqli_connect_errno, NULL)
+ PHP_FE(mysqli_connect_error, NULL)
PHP_FE(mysqli_data_seek, NULL)
PHP_FE(mysqli_debug, NULL)
PHP_FE(mysqli_disable_reads_from_master, NULL)
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index 86d4fc52a0..b0b6fc9460 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -76,6 +76,7 @@ PHP_FUNCTION(mysqli_connect)
mysql_close(mysql);
RETURN_FALSE;
}
+ php_mysqli_set_error(mysql_errno(mysql), (char *) mysql_error(mysql) TSRMLS_CC);
if (MyG(profiler)) {
prmysql = (PR_MYSQL *)MYSQLI_PROFILER_NEW(prmain, MYSQLI_PR_MYSQL, 0);
@@ -99,6 +100,22 @@ PHP_FUNCTION(mysqli_connect)
}
/* }}} */
+/* {{{ proto int mysqli_connct_errno()
+ Returns the numerical value of the error message from last connect command */
+PHP_FUNCTION(mysqli_connect_errno)
+{
+ RETURN_LONG(MyG(error_no));
+}
+/* }}} */
+
+/* {{{ proto string mysqli_connect_error()
+ Returns the text of the error message from previous MySQL operation */
+PHP_FUNCTION(mysqli_connect_error)
+{
+ RETURN_STRING(MyG(error_msg),1);
+}
+/* }}} */
+
/* {{{ proto array mysqli_fetch_array (object result [,int resulttype])
Fetch a result row as an associative array, a numeric array, or both */
PHP_FUNCTION(mysqli_fetch_array)
diff --git a/ext/mysqli/php_mysqli.h b/ext/mysqli/php_mysqli.h
index c9e72588fa..4b0ca26685 100644
--- a/ext/mysqli/php_mysqli.h
+++ b/ext/mysqli/php_mysqli.h
@@ -203,6 +203,8 @@ PHP_FUNCTION(mysqli_character_set_name);
PHP_FUNCTION(mysqli_close);
PHP_FUNCTION(mysqli_commit);
PHP_FUNCTION(mysqli_connect);
+PHP_FUNCTION(mysqli_connect_errno);
+PHP_FUNCTION(mysqli_connect_error);
PHP_FUNCTION(mysqli_data_seek);
PHP_FUNCTION(mysqli_debug);
PHP_FUNCTION(mysqli_disable_reads_from_master);