You are here: Re: Consensus on how to store arrays? « PHP Programming Language « IT news, forums, messages
Re: Consensus on how to store arrays?

Posted by Jim Michaels on 02/14/06 07:53

"Jim Michaels" <jmichae3@nospam.yahoo.com> wrote in message
news:7cidnYcQQ6gy8GzeRVn-uA@comcast.com...
> even though the serialized data should be stored as a VARBINARY or a BLOB,
> you could possibly still do a search using LIKE using your existing data
> type.
> the text data is embedded inside the serialized string as plaintext and
> should be searchable with LIKE %somestring% although a bit slower than
> other searches.

a caveat on this is that if you are searching for short things like a
number, that number may appear in the garbage part of the data, and you may
still need to filter things out after your query is done using
array_search() or maybe preg_grep() which can search through arrays for
matches.
http://us2.php.net/manual/en/function.array-search.php
http://us2.php.net/manual/en/function.preg-grep.php

>
> "thehuby" <thehuby@gmail.com> wrote in message
> news:1139847450.234541.310840@g43g2000cwa.googlegroups.com...
>>I think that using implode/explode would be the best way as this means
>> you can use native SQL to search the database (WHERE array_col LIKE
>> '%2%' or whatever), rather than having to comparison check each
>> serialised object by pulling the data out, transforming, doing an array
>> lookup etc.
>>
>> Quite a clever way of doing it actually!
>>
>> The other way of doing it would be to use SQL 'properly' and use a
>> table for whatever the array numbers of reference (I am assuming a PK
>> on another table or an index in an array), then using SQL to search
>> through the whole thing.
>>
>> Either way, avoiding serialization will allow you to port the language
>> at a later date to another language (ASP, JSP etc.). Not something you
>> might be thinking of right now but it could be useful.
>>
>
>

 

Navigation:

[Reply to this 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

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