user data table

Hi,



Just curious to figure out if I can use…



In the database there is a table named cscart_user_data. It has three fields. One of them is DATA field. This field contains a secret code as below as an example:



a:10:{i:0;a:4:{s:4:“func”;a:2:{i:0;s:19:“fn_get_product_name”;i:1;s:5:“29842”;}s:3:“url”;s:76:“admin.php?dispatch=products.update&product_id=29842&selected_section=options”;s:4:“icon”;s:12:“product-item”;s:4:“text”;s:7:“product”;}i:1;a:4:{s:4:“func”;a:2:{i:0;s:19:“fn_get_product_name”;i:1;s:5:“29842”;}s:3:“url”;s:51:“admin.php?dispatch=products.update&product_id=29842”;s:4:“icon”;s:12:“product-item”;s:4:“text”;s:7:“product”;}i:2;a:4:{s:4:“func”;a:2:{i:0;s:19:“fn_get_product_name”;i:1;s:5:“29842”;}s:3:“url”;s:77:“admin.php?dispatch=products.update&product_id=29842&selected_section=detailed”;s:4:“icon”;s:12:“product-item”;s:4:“text”;s:7:“product”;}i:3;a:4:{s:4:“func”;a:2:{i:0;s:19:“fn_get_product_name”;i:1;s:5:“29842”;}s:3:“url”;s:77:“admin.php?dispatch=products.update&product_id=29842&selected_section=detailed”;s:4:“icon”;s:12:“product-item”;s:4:“text”;s:7:“product”;}s:10:“2206427175”;a:4:{s:4:“func”;a:2:{i:0;s:16:“fn_get_user_name”;i:1;s:1:“1”;}s:3:“url”;s:44:“admin.php?dispatch=profiles.update&user_id=1”;s:4:“icon”;s:0:“”;s:4:“text”;s:4:“user”;}i:4;a:4:{s:4:“func”;a:2:{i:0;s:19:“fn_get_product_name”;i:1;s:5:“29842”;}s:3:“url”;s:51:“admin.php?dispatch=products.update&product_id=29842”;s:4:“icon”;s:12:“product-item”;s:4:“text”;s:7:“product”;}i:5;a:4:{s:4:“func”;a:2:{i:0;s:19:“fn_get_product_name”;i:1;s:5:“29842”;}s:3:“url”;s:51:“admin.php?dispatch=products.update&product_id=29842”;s:4:“icon”;s:12:“product-item”;s:4:“text”;s:7:“product”;}i:6;a:4:{s:4:“func”;a:2:{i:0;s:19:“fn_get_product_name”;i:1;s:5:“29842”;}s:3:“url”;s:76:“admin.php?dispatch=products.update&product_id=29842&selected_section=options”;s:4:“icon”;s:12:“product-item”;s:4:“text”;s:7:“product”;}i:7;a:4:{s:4:“func”;a:2:{i:0;s:19:“fn_get_product_name”;i:1;s:5:“29842”;}s:3:“url”;s:51:“admin.php?dispatch=products.update&product_id=29842”;s:4:“icon”;s:12:“product-item”;s:4:“text”;s:7:“product”;}i:8;a:4:{s:4:“func”;a:2:{i:0;s:19:“fn_get_product_name”;i:1;s:5:“29842”;}s:3:“url”;s:77:“admin.php?dispatch=products.update&product_id=29842&selected_section=detailed”;s:4:“icon”;s:12:“product-item”;s:4:“text”;s:7:“product”;}}



How do we interpret this? Why does the cs-cart make this field this way?



Thanks,

Secret code? LMAO!!!

When posting code please enclose it with either PHP or CODE tags so we can better understand what is happening. This mess above looks correct but something more apparent may be visible if we could actually read it.

S-comb,



That is an example of data in the “data” field in the database. I am sure cs-cart uses it in its codes. I would like to know how cs-cart interprets this data. I’ve never seen this kind of database design.



For example, the following is a part of data stored in the database as you can see in the beginning of data above.



a:10:{i:0;a:4:{s:4



What does it mean? It looks like there is a data structure built so the cs-cart code can interpret it.





Outfitters,

I said “secret code” since it is known only to the cs-cart developers in terms of decipherability, and not to us. Laughing does not help at all.

No offense, it was just funny.



You are absolutely correct, it is how the data is interpreted. There is no way to know exactly what each and every bit of data means unless you are the developer and/or you have hours, days, weeks, months, etc… to figure out what it means.

The secret code (secret sauce) is a php serialize() function. It creates a string representation of an array or other data: Hence an

array(‘this’ => ‘that’);

becomes

a:1:{s:4:“this”;s:4:“that”;}



Which decodes to:

‘a’ - type is array

‘:1’ - with one element

‘{’ - that contains

‘s4’ - a string of length 4 with a value of ‘this’ as the index of the array

‘s4’ - a string of lengh 4 with a value of ‘that’ as the value of the array element

‘}’ - end of contents.



It’s a cheap way to keep structured data in a single DB field that is not intended to be searchable. Trade off is that serialize() is somewhat expensive but less so than creating all the db tables that would be needed and the associated JOINs that would be required.

Ah~ it’s interesting.

Thanks much, tbirnseth.