|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
11 Oct 2000, Version 4.0.3
+- Added mysql_escape_string() (Peter A. Savitch and & Brian Wang)
- Fixed many possible crash bugs with improper use of the printf() family of
functions (Andi)
- Fixed a problem that allowed users to override admin_value's and admin_flag's
PHP_FE(mysql_field_len, NULL)
PHP_FE(mysql_field_type, NULL)
PHP_FE(mysql_field_flags, NULL)
+ PHP_FE(mysql_escape_string, NULL)
/* for downwards compatability */
PHP_FALIAS(mysql, mysql_db_query, NULL)
/* }}} */
+/* {{{ proto char mysql_escape_string([char string])
+ Escape string for mysql query */
+PHP_FUNCTION(mysql_escape_string)
+{
+ zval **str;
+
+ if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &str) == FAILURE) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+ convert_to_string_ex(str);
+ /* assume worst case situation, which is 2x of the original string.
+ * we don't realloc() down to the real size since it'd most probably not
+ * be worth it
+ */
+ Z_STRVAL_P(return_value) = (char *) emalloc(Z_STRLEN_PP(str)*2+1);
+ Z_STRLEN_P(return_value) = mysql_escape_string(Z_STRVAL_P(return_value), Z_STRVAL_PP(str), Z_STRLEN_PP(str));
+ return_value->type = IS_STRING;
+}
+/* }}} */
+
+
/* {{{ proto int mysql_insert_id([int link_identifier])
Get the id generated from the previous INSERT operation */
PHP_FUNCTION(mysql_insert_id)
PHP_FUNCTION(mysql_field_len);
PHP_FUNCTION(mysql_field_type);
PHP_FUNCTION(mysql_field_flags);
+PHP_FUNCTION(mysql_escape_string);
ZEND_BEGIN_MODULE_GLOBALS(mysql)
long default_link;