troy knapp - 2011-01-27 16:56:33 -
In reply to message 1 from Pashkov Denis Igorevich
I'm not entirely sure what you are asking, but I hope the following responce will clear things up...
Multidim's purpose is not to represent an array, but to manipulate it. If you want to serialize an array and store it in a database in a single field, then that would certainly be faster... but it would be much harder to manipulate the contents.
The slowest part of Multidim is the insert statement. Keep in mind what it's doing... if you have an array like:
array(
[0]=>array([0]=>'foo', [1]=>'bar', [2]=>123),
[1]=>array([0]=>'foo1', [1]=>'bar1', [3]=>21),
[2]=>array([0]=>'foo2', [1]=>'bar3', [2]=>890)
)
Multidim will conduct 3 inserts (one for each root array element). Now if you were to serialize the above array and insert it into a database, as one row, then it is trivially true that serialization would take less time. Even with the added mysqli_multi_query() functionality, serialization would take much less time.
However, if you were to take said serialized array and try to parse it and, for example, delete all elements in an array when the second order array element 2 (in other words: $temp=array[0]; target_filter_element=$temp[2])is greater than 21, multidim would do THAT much faster, and much more easily than the alternative.
Basically, I found myself creating 2 dimensional arrays all the time, and trying to interpret the data contained within. Multidim is especially optimized to help you in those kinds of cases.