Reply to Re: [PHP] Storing data structires in DB

Your name:

Reply:


Posted by Rasmus Lerdorf on 03/27/05 05:24

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация