]> granicus.if.org Git - php/commitdiff
new functions (4.1.1): mysql_sqlstate, mysql_stmt_sqlstate
authorGeorg Richter <georg@php.net>
Sat, 21 Jun 2003 13:35:26 +0000 (13:35 +0000)
committerGeorg Richter <georg@php.net>
Sat, 21 Jun 2003 13:35:26 +0000 (13:35 +0000)
ext/mysqli/mysqli_api.c
ext/mysqli/mysqli_fe.c
ext/mysqli/php_mysqli.h

index 52b2d609d4a0351893d57df373363168da3a6fbf..1514de3aed7489b212ef7e3bba0f9d7d85989169 100644 (file)
@@ -1725,6 +1725,24 @@ PHP_FUNCTION(mysqli_select_db)
 }
 /* }}} */
 
+/* {{{ proto string mysqli_sqlstate(resource link)
+   Returns the SQLSTATE error from previous MySQL operation */
+#if MYSQL_VERSION_ID >= 40101
+PHP_FUNCTION(mysqli_sqlstate) 
+{
+       MYSQL           *mysql;
+       zval            *mysql_link;
+       PR_MYSQL        *prmysql;
+
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
+               return;
+       }
+       MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, prmysql, PR_MYSQL *, &mysql_link, "mysqli_link");
+       RETURN_STRING((char *)mysql_sqlstate(mysql),1);
+}
+#endif
+/* }}} */
+
 /* {{{ proto string mysqli_ssl_set(resource link [,string key [,string cert [,string ca [,string capath [,string cipher]]]]])
 */
 PHP_FUNCTION(mysqli_ssl_set)
@@ -1819,6 +1837,25 @@ PHP_FUNCTION(mysqli_stmt_store_result)
 }
 /* }}} */
 
+/* {{{ proto string mysqli_stmt_error(resource stmt)
+*/
+#if MYSQL_VERSION_ID >= 40101
+PHP_FUNCTION(mysqli_stmt_sqlstate) 
+{
+       STMT    *stmt;
+       zval    *mysql_stmt;
+       PR_STMT *prstmt;
+
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
+               return;
+       }
+       MYSQLI_FETCH_RESOURCE(stmt, STMT *, prstmt, PR_STMT *, &mysql_stmt, "mysqli_stmt"); 
+       
+       RETURN_STRING((char *)mysql_stmt_sqlstate(stmt->stmt),1);
+}
+#endif
+/* }}} */
+
 /* {{{ proto resource mysqli_store_result(resource link)
    Buffer result set on client */
 PHP_FUNCTION(mysqli_store_result)
index 4618f939f16cbbfffd0a963c6c53430c73d32ed1..fd45d77c2030c64c6f83c288dd6cb04f76f217cd 100644 (file)
@@ -104,12 +104,19 @@ function_entry mysqli_functions[] = {
        PHP_FE(mysqli_send_query,                                                       NULL)
        PHP_FALIAS(mysqli_set_opt,              mysqli_options,         NULL)
        PHP_FE(mysqli_slave_query,                                                      NULL)
+
+#if MYSQL_VERSION_ID >= 40101
+       PHP_FE(mysqli_sqlstate,                                                         NULL)
+#endif
        PHP_FE(mysqli_ssl_set,                                                          NULL)
        PHP_FE(mysqli_stat,                                                                     NULL)
        PHP_FE(mysqli_stmt_affected_rows,                                       NULL)
        PHP_FE(mysqli_stmt_close,                                                       NULL)
        PHP_FE(mysqli_stmt_errno,                                                       NULL)
        PHP_FE(mysqli_stmt_error,                                                       NULL)
+#if MYSQL_VERSION_ID >= 40101
+       PHP_FE(mysqli_stmt_sqlstate,                                            NULL)
+#endif
        PHP_FE(mysqli_store_result,                                                     NULL)
        PHP_FE(mysqli_stmt_store_result,                                        NULL)
        PHP_FE(mysqli_thread_id,                                                        NULL)
@@ -168,6 +175,9 @@ function_entry mysqli_link_methods[] = {
        PHP_FALIAS(select_db,mysqli_select_db,NULL)
        PHP_FALIAS(set_opt, mysqli_options,NULL)
        PHP_FALIAS(slave_query,mysqli_slave_query,NULL)
+#if MYSQL_VERSION_ID >= 40101
+       PHP_FALIAS(sqlstate, mysqli_sqlstate,NULL)
+#endif
        PHP_FALIAS(ssl_set,mysqli_ssl_set,NULL)
        PHP_FALIAS(stat,mysqli_stat,NULL)
        PHP_FALIAS(store_result,mysqli_store_result,NULL)
@@ -221,6 +231,9 @@ function_entry mysqli_stmt_methods[] = {
        PHP_FALIAS(close,mysqli_stmt_close,NULL)
        PHP_FALIAS(errno,mysqli_stmt_errno,NULL)
        PHP_FALIAS(error,mysqli_stmt_error,NULL)
+#if MYSQL_VERSION_ID >= 40101
+       PHP_FALIAS(sqlstate, mysqli_stmt_sqlstate,NULL)
+#endif
        {NULL, NULL, NULL}
 };
 /* }}} */
index 06d17487de4691c04cdbce387e53b531f59cc9cb..b43d2d3a0aa27d524930173351720b4f4bb59b98 100644 (file)
@@ -254,12 +254,18 @@ PHP_FUNCTION(mysqli_select_db);
 PHP_FUNCTION(mysqli_send_long_data);
 PHP_FUNCTION(mysqli_send_query);
 PHP_FUNCTION(mysqli_slave_query);
+#if MYSQL_VERSION_ID >= 40101
+PHP_FUNCTION(mysqli_sqlstate);
+#endif
 PHP_FUNCTION(mysqli_ssl_set);
 PHP_FUNCTION(mysqli_stat);
 PHP_FUNCTION(mysqli_stmt_affected_rows);
 PHP_FUNCTION(mysqli_stmt_close);
 PHP_FUNCTION(mysqli_stmt_errno);
 PHP_FUNCTION(mysqli_stmt_error);
+#if MYSQL_VERSION_ID >= 40101
+PHP_FUNCTION(mysqli_stmt_sqlstate);
+#endif
 PHP_FUNCTION(mysqli_stmt_store_result);
 PHP_FUNCTION(mysqli_store_result);
 PHP_FUNCTION(mysqli_thread_id);