I am Involve a CodeIgniter Project.In this project another developer insert cat_id in the database include # separated like #1#. when insert two cat_id the value store in database like #1##2#.
Now I want to retrieve the cat_id and join it to the another table.
3
Answers
Ok, I’ve made a mistake in my first attempt (find bellow), this hopfully this should work:
Bonus if you want to reset the array keys to start from 0 again:
Old incorrect answer:
I strongly suggest you into changing your PHP code and MySQL tables into supporting normalisation.
Because the needed query to fetch (“parse”) a cat_id number from
#1##2#
is a total nightmare and will not perform well.The query looks more or less like this without the extra join to a other table.
But then i feel the next question coming.
So now a PHP example to parse out cat_ids
PHP code
Result
You can try this,
Here is working demo.