]> granicus.if.org Git - php/commitdiff
added new function mysqli_get_charset
authorGeorg Richter <georg@php.net>
Fri, 3 Jun 2005 08:49:01 +0000 (08:49 +0000)
committerGeorg Richter <georg@php.net>
Fri, 3 Jun 2005 08:49:01 +0000 (08:49 +0000)
NEWS
ext/mysqli/mysqli_fe.c
ext/mysqli/mysqli_nonapi.c
ext/mysqli/php_mysqli.h

diff --git a/NEWS b/NEWS
index fe5b7e3632d94759d38ffb7931d10e7ad7ec2570..7392e0567cd32b7308e4b9cf03392398b281ef97 100644 (file)
--- 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)
index 31d1790c3b2b3bc806e23a764521fdb926e3df22..034321ebaa58f3770480a570cd0339329f62b22d 100644 (file)
@@ -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)
index e5f3cda7933285630cec5a66f402c4aeb7177b99..77a3eb426247af605b13315bd31764a7ee4138aa 100644 (file)
@@ -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
index 4531bcd4ded8e67ee756d81cc5ea95f820f9c7b5..b37af76add6ca6124b3430899d8a66802b4fae85 100644 (file)
@@ -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);