I have attatched a patch to do recordset, datetime, and field tags processing
during deserialization.
On Thu, 8 Nov 2001, Andrei Zmievski wrote:
> On Thu, 08 Nov 2001, [EMAIL PROTECTED] wrote:
> > Hi all:
> >
> > I am thinking of a way to transform WDDX recordset element into PHP varialbles
> > when deserializing the packet.
> >
> > It seems that all recordset will look like:
> >
> > <var name="queryname"><recordset rowcount="?" fieldname="f1,f2,...fn"><field
> > name="f1">...</field>...</recordset></var>
> >
> > The above can be transformed into:
> >
> > <var name="queryname"><string>f1,f2,...fn</string></var><var
> > name="f1"><array>...</array></var><var name="f2"><array>...</array></var>...
> >
> > If we parse as this transformation, in PHP script:
> >
> > $values = wddx_deserialize($packet);
> > $values["queryname"] = "f1,f2,...,fn";
> > $values["f1"] = values in array for "f1" field;
> > ....
> > $values["fn"] = values in array for "fn" field;
> >
> >
> > Should this solve the recordset problem?
>
> Deserializing the recordset is not a problem, but creating one out of
> PHP values is since there is no exact mapping. It would be better to
> have it work both ways, but maybe deserialization only support at this
> point is fine.
>
> -Andrei
Phillip Pan
-----------
Index: wddx.c
===================================================================
RCS file: /home/phillip/CVS/php/ext/wddx/wddx.c,v
retrieving revision 1.1.1.1
diff -u -w -r1.1.1.1 wddx.c
--- wddx.c 2001/11/08 23:31:11 1.1.1.1
+++ wddx.c 2001/11/09 00:45:05
@@ -59,6 +59,9 @@
#define EL_VAR "var"
#define EL_VAR_NAME "name"
#define EL_VERSION "version"
+#define EL_RECORDSET "recordset"
+#define EL_FIELD "field"
+#define EL_DATETIME "datetime"
#define php_wddx_deserialize(a,b) \
php_wddx_deserialize_ex((a)->value.str.val, (a)->value.str.len, (b))
@@ -95,6 +98,7 @@
static void php_wddx_process_data(void *user_data, const char *s, int len);
+static void php_wddx_pop_element(void *user_data, const char *name);
function_entry wddx_functions[] = {
@@ -561,7 +565,7 @@
/* nothing for now */
}
}
- } else if (!strcmp(name, EL_STRING)) {
+ } else if (!strcmp(name, EL_STRING) || !strcmp(name, EL_DATETIME)) {
ent.type = ST_STRING;
SET_STACK_VARNAME;
@@ -650,12 +654,43 @@
stack->varname = decoded_value;
}
}
+ } else if (!strcmp(name, EL_RECORDSET)) {
+ int i;
+ ent.type = ST_STRING;
+ SET_STACK_VARNAME;
+
+ ALLOC_ZVAL(ent.data);
+ INIT_PZVAL(ent.data);
+ Z_TYPE_P(ent.data) = IS_STRING;
+ Z_STRVAL_P(ent.data) = empty_string;
+ Z_STRLEN_P(ent.data) = 0;
+ wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
+ for ( i = 0; atts[i]; i++ ) {
+ if (!strcmp(atts[i], "fieldNames")) {
+ break;
}
- /*
- else if (!strcmp(name, EL_RECORDSET)) {
- ent.type = ST_RECORDSET;
}
- */
+ php_wddx_process_data(user_data, atts[i++], strlen(atts[i++]));
+ php_wddx_pop_element(user_data, EL_STRING);
+ } else if (!strcmp(name, EL_FIELD)) {
+ int i;
+
+ for (i=0; atts[i]; i++) {
+ if (!strcmp(atts[i], EL_VAR_NAME) && atts[i+1]) {
+ char *decoded_value;
+ int decoded_len;
+ decoded_value =
+xml_utf8_decode(atts[i+1],strlen(atts[i+1]),&decoded_len,"ISO-8859-1");
+ stack->varname = decoded_value;
+ }
+ }
+ ent.type = ST_ARRAY;
+ SET_STACK_VARNAME;
+
+ ALLOC_ZVAL(ent.data);
+ array_init(ent.data);
+ INIT_PZVAL(ent.data);
+ wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
+ }
}
@@ -675,7 +710,8 @@
if (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) ||
!strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) ||
!strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) ||
- !strcmp(name, EL_BINARY)) {
+ !strcmp(name, EL_BINARY) || !strcmp(name, EL_FIELD) ||
+ !strcmp(name, EL_DATETIME)) {
wddx_stack_top(stack, (void**)&ent1);
if (!strcmp(name, EL_BINARY)) {
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]