Re: Storing data structires in DB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



GamblerZG wrote:
Why would you _manually_ edit a serialized array??? One would think you would UNSERIALIZE (http://us4.php.net/unserialize) the serialized array *before* working with the data.


Well, I guess my initial posting was a bit misleading. I'm writing a content management system, and that system needs to give its users ability to create arbitrary data structures. Suppose users should be able to create hyperlinked menus. Each menu entry must have text, URL and, possibly, title. There are several ways to achieve such functionality.

1) Write big and ugly interface that does only that – creates menus. Not very smart, because tomorrow users might need to create nested categories or some other things.
2) Invent your own syntax for menu programming and write small, but still ugly procedure that parses that syntax.
3) Invent your own syntax for data structure programming, and write function that parses it into PHP data structures. Almost a good solution, but then I would need some way to store, retrieve and edit data.
4) Use something that already exists.


If I can, I would prefer to stick with 4. After all, PHP has var_export() and eval(). The problem is, var_export() stuffs its output with junk (extra commas, newlines, spaces), and eval() executes any code.

You are looking for serialize here. I bet you'd be better off with an existing XML format for something like this though.


-Rasmus

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux