summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Richter <georg@php.net>2005-06-03 08:49:01 +0000
committerGeorg Richter <georg@php.net>2005-06-03 08:49:01 +0000
commitd486da963e02271623db034adde6fc55d9fcb6cb (patch)
tree3370693d63e1f3efe0798ca372966ee4415daeff
parentd3a665248d1850987164368393cedb289214c73c (diff)
downloadphp-git-d486da963e02271623db034adde6fc55d9fcb6cb.tar.gz
added new function mysqli_get_charset
-rw-r--r--NEWS10
-rw-r--r--ext/mysqli/mysqli_fe.c2
-rw-r--r--ext/mysqli/mysqli_nonapi.c25
-rw-r--r--ext/mysqli/php_mysqli.h27
4 files changed, 61 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index fe5b7e3632..7392e0567c 100644
--- a/NEWS
+++ b/NEWS
@@ -57,6 +57,13 @@ PHP NEWS
. pg_result_error_field() - highly detailed error information,
most importantly the SQLSTATE error code.
. pg_set_error_verbosity() - set verbosity of errors.
+- Improved extension mysqli (Georg)
+ . added constructor for mysqli_stmt and mysqli_result classes
+ . added new function mysqli_get_charset
+ . added new class mysqli_driver
+ . added new class mysqli_warning
+ . added new class mysqli_execption
+ . added new class mysqli_sql_exception
- Added optional fifth parameter "count" to preg_replace_callback() and
preg_replace() to count the number of replacements made. FR #32275. (Andrey)
- Added optional third parameter "charlist" to str_word_count() which
@@ -65,10 +72,7 @@ PHP NEWS
- Added pg_field_type_oid() PostgreSQL function. (mauroi at digbang dot com)
- Added zend_declare_property_...() and zend_update_property_...()
API functions for bool, double and binary safe strings. (Hartmut)
-- Added new classes in mysqli: mysqli_driver, mysqli_warning, mysqli_exception,
- and mysqli_sql_exception. (Georg)
- Added possibility to access INI variables from within .ini file. (Andrei)
-- Added constructors for mysqli_stmt and mysqli_result classes. (Georg)
- Added variable $_SERVER['REQUEST_TIME'] containing request start time. (Ilia)
- Added optional float parameter to gettimeofday(). (Ilia)
- Added apache_reset_timeout() Apache1 function. (Rasmus)
diff --git a/ext/mysqli/mysqli_fe.c b/ext/mysqli/mysqli_fe.c
index 31d1790c3b..034321ebaa 100644
--- a/ext/mysqli/mysqli_fe.c
+++ b/ext/mysqli/mysqli_fe.c
@@ -85,6 +85,7 @@ function_entry mysqli_functions[] = {
PHP_FE(mysqli_field_seek, NULL)
PHP_FE(mysqli_field_tell, NULL)
PHP_FE(mysqli_free_result, NULL)
+ PHP_FE(mysqli_get_charset, NULL)
PHP_FE(mysqli_get_client_info, NULL)
PHP_FE(mysqli_get_client_version, NULL)
PHP_FE(mysqli_get_host_info, NULL)
@@ -191,6 +192,7 @@ function_entry mysqli_link_methods[] = {
PHP_FALIAS(dump_debug_info,mysqli_dump_debug_info,NULL)
PHP_FALIAS(enable_reads_from_master,mysqli_enable_reads_from_master,NULL)
PHP_FALIAS(enable_rpl_parse,mysqli_enable_rpl_parse,NULL)
+ PHP_FALIAS(get_charset,mysqli_get_charset,NULL)
PHP_FALIAS(get_client_info,mysqli_get_client_info,NULL)
PHP_FALIAS(get_server_info,mysqli_get_server_info,NULL)
PHP_FALIAS(get_warnings, mysqli_warning_construct, NULL)
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index e5f3cda793..77a3eb4262 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -274,6 +274,31 @@ PHP_FUNCTION(mysqli_set_charset)
/* }}} */
#endif
+/* {{{ object mysqli_get_charset(object link)
+ returns a character set object */
+PHP_FUNCTION(mysqli_get_charset)
+{
+ MY_MYSQL *mysql;
+ zval *mysql_link;
+ CHARSET_INFO *cs;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
+ return;
+ }
+ MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link");
+
+ object_init(return_value);
+
+ cs = (CHARSET_INFO *)mysql->mysql->charset;
+
+ add_property_string(return_value, "charset", (cs->name) ? (char *)cs->csname : "", 1);
+ add_property_string(return_value, "collation",(cs->name) ? (char *)cs->name : "", 1);
+ add_property_string(return_value, "comment", (cs->comment) ? (char *)cs->comment : "", 1);
+ add_property_long(return_value, "min_length", cs->mbminlen);
+ add_property_long(return_value, "max_length", cs->mbmaxlen);
+}
+/* }}} */
+
/*
* Local variables:
* tab-width: 4
diff --git a/ext/mysqli/php_mysqli.h b/ext/mysqli/php_mysqli.h
index 4531bcd4de..b37af76add 100644
--- a/ext/mysqli/php_mysqli.h
+++ b/ext/mysqli/php_mysqli.h
@@ -95,6 +95,32 @@ typedef struct {
void *userdata;
} mysqli_local_infile;
+typedef struct {
+ uint number;
+ uint primary_number;
+ uint binary_number;
+ uint state;
+ const char *csname;
+ const char *name;
+ const char *comment;
+ const char *tailoring;
+ unsigned char *ctype;
+ unsigned char *to_lower;
+ unsigned char *to_upper;
+ unsigned char *sort_order;
+ unsigned short *contractions;
+ unsigned short **sort_order_big;
+ unsigned short *tab_to_uni;
+ void *tab_from_uni;
+ unsigned char *state_map;
+ unsigned char *ident_map;
+ uint strxfrm_multiply;
+ uint mbminlen;
+ uint mbmaxlen;
+ unsigned short min_sort_char;
+ unsigned short max_sort_char; /* For LIKE optimization */
+} CHARSET_INFO;
+
#define phpext_mysqli_ptr &mysqli_module_entry
#ifdef PHP_WIN32
@@ -326,6 +352,7 @@ PHP_FUNCTION(mysqli_field_count);
PHP_FUNCTION(mysqli_field_seek);
PHP_FUNCTION(mysqli_field_tell);
PHP_FUNCTION(mysqli_free_result);
+PHP_FUNCTION(mysqli_get_charset);
PHP_FUNCTION(mysqli_get_client_info);
PHP_FUNCTION(mysqli_get_client_version);
PHP_FUNCTION(mysqli_get_host_info);