[PHP-CVS] cvs: php-src(PHP_5_2) / NEWS /ext/mysql php_mysql.c php_mysql.h

2007-05-14 Thread Scott MacVicar
scottmacMon May 14 17:10:47 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-srcNEWS 
/php-src/ext/mysql  php_mysql.c php_mysql.h 
  Log:
  Add mysql_set_charset() so that the connection encoding can be changed. This 
is similar to the SET NAMES statement but allows the mysql_real_escape_string 
to use the correct character set.
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.700r2=1.2027.2.547.2.701diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.700 php-src/NEWS:1.2027.2.547.2.701
--- php-src/NEWS:1.2027.2.547.2.700 Mon May 14 11:45:38 2007
+++ php-src/NEWSMon May 14 17:10:46 2007
@@ -1,6 +1,8 @@
 PHPNEWS
 |||
 ?? ??? 2007, PHP 5.2.3
+- Added function mysql_set_charset(). Allows connection encoding to be altered
+  at run time. (Scott)
 - Allow SOAP extension's handler() to work even when
   always_populate_raw_post_data is off. (Ilia)
 - Fixed ext/filter Email Validation Vulnerability (MOPB-24 by Stefan Esser)
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/php_mysql.c?r1=1.213.2.6.2.10r2=1.213.2.6.2.11diff_format=u
Index: php-src/ext/mysql/php_mysql.c
diff -u php-src/ext/mysql/php_mysql.c:1.213.2.6.2.10 
php-src/ext/mysql/php_mysql.c:1.213.2.6.2.11
--- php-src/ext/mysql/php_mysql.c:1.213.2.6.2.10Mon Apr 23 09:32:44 2007
+++ php-src/ext/mysql/php_mysql.c   Mon May 14 17:10:46 2007
@@ -18,7 +18,7 @@
+--+
 */
  
-/* $Id: php_mysql.c,v 1.213.2.6.2.10 2007/04/23 09:32:44 tony2001 Exp $ */
+/* $Id: php_mysql.c,v 1.213.2.6.2.11 2007/05/14 17:10:46 scottmac Exp $ */
 
 /* TODO:
  *
@@ -101,6 +101,10 @@
 #define MYSQL_HAS_YEAR
 #endif
 
+#if (MYSQL_VERSION_ID = 40113  MYSQL_VERSION_ID  5) || 
MYSQL_VERSION_ID = 50007
+#define MYSQL_HAS_SET_CHARSET
+#endif
+
 #define MYSQL_ASSOC10
 #define MYSQL_NUM  11
 #define MYSQL_BOTH (MYSQL_ASSOC|MYSQL_NUM)
@@ -181,7 +185,9 @@
 #endif
 
PHP_FE(mysql_info,  
NULL)
-
+#ifdef MYSQL_HAS_SET_CHARSET
+   PHP_FE(mysql_set_charset,   
NULL)
+#endif
/* for downwards compatability */
PHP_FALIAS(mysql,   mysql_db_query, 
NULL)
PHP_FALIAS(mysql_fieldname, mysql_field_name,   NULL)
@@ -1124,6 +1130,36 @@
 /* }}} */
 #endif
 
+#ifdef MYSQL_HAS_SET_CHARSET
+/* {{{ proto bool mysql_set_charset(string csname [, int link_identifier])
+   sets client character set */
+PHP_FUNCTION(mysql_set_charset)
+{
+   zval *mysql_link = NULL;
+   char *csname;
+   int id = -1, csname_len;
+   php_mysql_conn *mysql;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|r, csname, 
csname_len, mysql_link) == FAILURE) {
+   WRONG_PARAM_COUNT;
+   }
+
+   if (ZEND_NUM_ARGS() == 1) {
+   id = 
php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+   CHECK_LINK(id);
+   }
+
+   ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, id, 
MySQL-Link, le_link, le_plink);
+
+   if (!mysql_set_character_set(mysql-conn, csname)) {
+   RETURN_TRUE;
+   } else {
+   RETURN_FALSE;
+   }
+}
+/* }}} */
+#endif
+
 #ifndef NETWARE/* The below two functions not supported on 
NetWare */
 #if MYSQL_VERSION_ID  4
 /* {{{ proto bool mysql_create_db(string database_name [, int link_identifier])
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/php_mysql.h?r1=1.37.2.1.2.1r2=1.37.2.1.2.2diff_format=u
Index: php-src/ext/mysql/php_mysql.h
diff -u php-src/ext/mysql/php_mysql.h:1.37.2.1.2.1 
php-src/ext/mysql/php_mysql.h:1.37.2.1.2.2
--- php-src/ext/mysql/php_mysql.h:1.37.2.1.2.1  Mon Jan  1 09:36:03 2007
+++ php-src/ext/mysql/php_mysql.h   Mon May 14 17:10:47 2007
@@ -17,7 +17,7 @@
 */
 
 
-/* $Id: php_mysql.h,v 1.37.2.1.2.1 2007/01/01 09:36:03 sebastian Exp $ */
+/* $Id: php_mysql.h,v 1.37.2.1.2.2 2007/05/14 17:10:47 scottmac Exp $ */
 
 #ifndef PHP_MYSQL_H
 #define PHP_MYSQL_H
@@ -91,6 +91,9 @@
 PHP_FUNCTION(mysql_thread_id);
 PHP_FUNCTION(mysql_client_encoding);
 PHP_FUNCTION(mysql_ping);
+#if (MYSQL_VERSION_ID = 40113  MYSQL_VERSION_ID  5) || 
MYSQL_VERSION_ID = 50007
+PHP_FUNCTION(mysql_set_charset);
+#endif
 
 ZEND_BEGIN_MODULE_GLOBALS(mysql)
long default_link;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_2) / NEWS /ext/mysql php_mysql.c php_mysql.h

2007-05-14 Thread Antony Dovgal

On 05/14/2007 09:10 PM, Scott MacVicar wrote:

scottmacMon May 14 17:10:47 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src	NEWS 
/php-src/ext/mysql	php_mysql.c php_mysql.h 
  Log:
  Add mysql_set_charset() so that the connection encoding can be changed. 
This is similar to the SET NAMES statement but allows the mysql_real_escape_string to use the correct character set.


When and where was this discussed?

--
Wbr, 
Antony Dovgal


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_2) / NEWS /ext/mysql php_mysql.c php_mysql.h

2007-05-14 Thread Scott MacVicar
Was discussed last summer and again in January this year, I forgot about
 it for 5.2.2 until recently.

http://news.php.net/php.internals/27634

http://news.php.net/php.internals/27638

Spoke to ilia on IRC on Friday and his only comment was to use the new
param parsing API.

Scott

Antony Dovgal wrote:
 On 05/14/2007 09:10 PM, Scott MacVicar wrote:
 scottmacMon May 14 17:10:47 2007 UTC

   Modified files:  (Branch: PHP_5_2)
 /php-srcNEWS /php-src/ext/mysqlphp_mysql.c php_mysql.h
   Log:
   Add mysql_set_charset() so that the connection encoding can be
 changed. This is similar to the SET NAMES statement but allows the
 mysql_real_escape_string to use the correct character set.
 
 When and where was this discussed?
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_2) / NEWS /ext/mysql php_mysql.c php_mysql.h

2007-05-14 Thread Ilia Alshanetsky

Tony,

it was also discussed on internals back in 5.2.1 days, but it was too  
late to include due to the state of the release cycle at the time.


On 14-May-07, at 1:21 PM, Antony Dovgal wrote:


On 05/14/2007 09:10 PM, Scott MacVicar wrote:

scottmacMon May 14 17:10:47 2007 UTC
  Modified files:  (Branch: PHP_5_2)
/php-src	NEWS /php-src/ext/mysql	php_mysql.c php_mysql.h
Log:
  Add mysql_set_charset() so that the connection encoding can be  
changed. This is similar to the SET NAMES statement but allows the  
mysql_real_escape_string to use the correct character set.


When and where was this discussed?

--
Wbr, Antony Dovgal

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Ilia Alshanetsky

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php