⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Bug ?



Robert
  • profile picture
  • Member

Posted 26 June 2013 - 09:27 AM

Here is my problem :

 

 ->field_type('xxxx','multiselect', array( "1" => "aaaa", "2" => "bbbb", "3" => "cccc", "4" => "dddd", "5" => "eeee")); all works good, but when is added in to table i get 1,2,3,4,5 normal ..now when i do a search for lets say aaaa on the table i get no rezoults because in the table its not aaaa but 1. I fix this by :

 ->field_type('xxxx','multiselect', array( "aaaa" => "aaaa", "bbbb" => "bbbb", "cccc" => "cccc", "dddd" => "dddd", "eeee" => "eeee")); so now in the table is added aaaa,bbbb and i can do search on them. Is this normal or is this a bug ?

 


Amit Shah
  • profile picture
  • Member

Posted 26 June 2013 - 10:57 AM

Technically this seems to be normal. What the GC is making the data being stored in multiselect is whatever value is presented in index / key of the array. This dont seems to be bug at all.


Robert
  • profile picture
  • Member

Posted 26 June 2013 - 13:14 PM

I see then the examples need to be modify, if someone uses 1,2,3,4 they will not be able to use search on that field.


Amit Shah
  • profile picture
  • Member

Posted 26 June 2013 - 15:43 PM

If you want to search for a text, you need to store text .. database wont understand / match index number to text :)


davidoster
  • profile picture
  • Member

Posted 27 June 2013 - 07:57 AM

Here is my problem :

 

 ->field_type('xxxx','multiselect', array( "1" => "aaaa", "2" => "bbbb", "3" => "cccc", "4" => "dddd", "5" => "eeee")); all works good, but when is added in to table i get 1,2,3,4,5 normal ..now when i do a search for lets say aaaa on the table i get no rezoults because in the table its not aaaa but 1. I fix this by :

 ->field_type('xxxx','multiselect', array( "aaaa" => "aaaa", "bbbb" => "bbbb", "cccc" => "cccc", "dddd" => "dddd", "eeee" => "eeee")); so now in the table is added aaaa,bbbb and i can do search on them. Is this normal or is this a bug ?

 

You should use this approach, ->field_type('xxxx','multiselect', array( "1" => "aaaa", "2" => "bbbb", "3" => "cccc", "4" => "dddd", "5" => "eeee"));

When GC sees a field_type creates an internal array of the array the application gives (array( "1" => "aaaa", "2" => "bbbb", "3" => "cccc", "4" => "dddd", "5" => "eeee")

) in order when it sees value of 1 from the database it displays aaaa.


Amit Shah
  • profile picture
  • Member

Posted 28 June 2013 - 04:26 AM

Very true david, but if you read along, he have had a requirement of searching the aaaa, bbbb from database and that he will not be able to do it with the 1 mentioned above.


davidoster
  • profile picture
  • Member

Posted 28 June 2013 - 04:47 AM

Very true david, but if you read along, he have had a requirement of searching the aaaa, bbbb from database and that he will not be able to do it with the 1 mentioned above.

It shouldn't be done this way! For several reasons actually.

1. waste of bytes

2. referential integrity, e.g. what happens if someone goes and changes the aaaa key part (or even value part) of your array? how do you find the aaaa after this?

It's like saying " I look for the BMW oops I don't know the model type"!

3. why the search on the database is done via the value and not via the key part since you assign an array of type key => value? why don't you just assign a simple set instead?


Amit Shah
  • profile picture
  • Member

Posted 28 June 2013 - 08:23 AM

Welll i agree with the concepts. . and all perfect as you mentioned but that's at times.. users requirements. He could have had used enum / set in the table definition, but he still want to opt it like that.. its his choice .. cant help brother :)