php - How i can use REGEXP+mysql+procedure together -


i creating function find category id. because of categories values stored in mysql database php serialize , encoded json result looks :

"a:2:{i:0;s:1:\"1\";i:1;s:2:\"50\";}" 

i can use simple mysql statement , that's working fine regexp :

select * provider_cat_subcat category_id regexp '\\"\50.\\"' 

but want create procedure can put variable value. when trying :

where provider_cat_subcat.category_id regexp '\\"' + cat_id + '.\"' 

it's not working think because regexp. please me know how can join variable regexp or there's why can use php.

full procedure:

begin     select * provider_cat_subcat     provider_cat_subcat.category_id regexp '\\"' + cat_id + '.\"'    , provider_cat_subcat.subcategory_id regexp '\\"' + subcat_id + '.\"';  end 

thanks

could try please ?

delimiter $$ create procedure cat_regexp_search(in cat_id int(11), in sub_cat_id int(11)) begin   set @cat_id    := cat_id;   set @sub_cat_id := sub_cat_id;    select * provider_cat_subcat     provider_cat_subcat.category_id regexp concat('\\"', @cat_id, '.\\"')    , provider_cat_subcat.subcategory_id regexp concat('\\"', @sub_cat_id, '.\\"');  end $$ delimiter ; 

you should call script call cat_regexp_search(1, 3); when want edit call as

drop procedure if exists cat_regexp_search; 

then execute create script again.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -