I want to retrieve 1 and 2 form #1##2# . I don't change the database
or insert code
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.
SELECT
DISTINCT
REVERSE(
REVERSE(
SUBSTRING_INDEX(SUBSTRING_INDEX(<table>.<column>, '##', rows.row), '##', -1)
) >> 1 ) AS cat_id
FROM (
SELECT
@row := @row + 1 AS ROW
FROM (
SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9
) row1
CROSS JOIN (
SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9
) row2
CROSS JOIN (
SELECT @row := 0
) init_user_params
)
ROWS
CROSS JOIN
<table>
But then i feel the next question coming.
How can i convert that SQL into codeignitor's code?
So now a PHP example to parse out cat_ids
PHP code
<?php
$text = "#1##2##10000";
$cat_ids = explode("##", trim($text, '#'));
var_dump($cat_ids);
?>
Result
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(5) "10000"
}