ajax dynamic object (associative array-like) into two MySQL tables via PDO
I have a js dynamic object that I "stringified" via
JSON.stringify(obj_to_str);
I'm able to receive this object in a php file under the super-global
$_POST. The object's format (once in the $_POST super-global) looks like
this:
{"6869lx":"mds","2416ex":"mdr","5126mv":"mdf","7079px":"dtr","5350ds":"dts"}.
I'd like to be able to insert each key-value pare into a different table
-for instance: 6869lx into a table called 'key', and on the same row on a
different table called 'cat', mds.
The problem I'm having is to prepare a dynamic PDO statement to insert
this js object into two different MySQL tables (considering the fact that
I do not know the length of the object before-hand). I also read that if
the object is very large a for loop (or any type of php loop) would slow
down the insertion process.
What would be the best way of doing this? Thanks much in advance.
No comments:
Post a Comment