Re: search in serialized string
| From: | Rodrigo Peres | Date: | Sat, 24 Aug 2002 15:14:22 +0000 |
| Subject: | Re: search in serialized string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-113942@lists.php.net to get a copy of this message | ||
By serialized I mean using serialize(). This system was not develop by me,
I'am doing some modifications in it. When the user chooses a language and
his skill in it, thi sinformation is stored in array, passed to serialize()
and then stored in DB. This is the problem, now how can I search this string
correctly, since the string is serialized??
on 8/24/02 11:45 AM, DL Neil at PHPml@DandE.HomeChoice.co.uk wrote:
> Hi Rodrigo,
>
>> I have a form to post resumes. In one parte the user have a option to
> choose
>> up to 5 languages and his knowledge in it. example : english: basic
> advanced
>> ....
>> My problem is that was stored serialized in the BD and now I need to do a
>> search by language and knowledge. How can I do this. I've tried everything
>> unsuccessfully. example: search english advanced. If the user have english
>> basic and another advanced he/her appear in the search.
>
>
> Is it my imagination or have we seen this question posted to the list
> numerous times?
>
> Can we assume a "BD" means db/database?
> What do you mean by "serialised"?
>
> If I speak English very well and can managed basic greetings etc in Spanish
> would you enter both of my (supposed) language skills in one field or would
> each language appear in its own field/separate rows?
>
> If the table is properly designed/normalised, ie each language and level of
> skill is in its own field, then why can't you do something like:
>
> ...WHERE field LIKE "%english%" AND field LIKE "%advanced%"
>
> However I would think about having a field for language-name accompanied by
> another field for skill-level. This would get you away from those wild-cards
> and into faster queries that can use indexes, eg
>
> ...WHERE ( language = "english" ) AND ( level = "advanced" ) --or even
> "A"
> for advanced
>
> Perhaps if you gave us some examples of what you want to happen, and the
> code you are currently using, we could offer more specific information -
> repeating an unsuccessful question invites repetition of the non-answer!
>
> Regards,
> =dn
>
--