Searching with serialized id's - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Searching with serialized id's (/showthread.php?tid=66474) |
Searching with serialized id's - wolfgang1983 - 10-25-2016 When the user types in the search PHP it should find the questions that have category id of 1 I store my category id in a column in question called "tags" it's serialized of couse because the user may have chosen multiple tags / categories. The category table name is category and columns "category_id" "name" "status" a:2:{i:0;s:1:"1";i:1;s:1:"4";} I can search for questions fine but cannot search if it is a category they are searching for. Any idea's and examples thanks for your time PHP Code: public function get_questions($search) { Controller PHP Code: <?php RE: Searching with serialized id's - Narf - 10-25-2016 If you want it to be searchable, don't serialize it. RE: Searching with serialized id's - wolfgang1983 - 10-25-2016 (10-25-2016, 07:02 AM)Narf Wrote: If you want it to be searchable, don't serialize it. What would you recommend. RE: Searching with serialized id's - JayAdra - 10-25-2016 You need a one-to-many relationship with two tables, one for questions, one for categories/tags. Then use a table join to select the tags based on the question id. So your DB might be for example: Code: question RE: Searching with serialized id's - wolfgang1983 - 10-25-2016 (10-25-2016, 05:03 PM)JayAdra Wrote: You need a one-to-many relationship with two tables, one for questions, one for categories/tags. Then use a table join to select the tags based on the question id. Thank you I will look in to it tonight. Am trying to get bit more better in my coding. RE: Searching with serialized id's - d4jk4 - 10-25-2016 Use mongoDb for search, or ElasticSearch is good option |