Hello forums!
I was just wondering to know how this can be accomplished: Case:
Code:
SELECT * FROM cms_pages WHERE body LIKE '%keywords%';
Problem: Suppose my keyword=font & body field contains:
[code=text]<div style="font-size:12px">This is a body area</div>[/code]
then above query fetches this row.
I would like to know,
is there any function to strip the html tags while executing query?
something like:
Code:
SELECT * FROM cms_pages WHERE strip_tags(body) LIKE '%keywords%';
AFAIK there's nothing built in. You could build a SQL function I'm sure, but personally I would just store 2 versions of the content, one with tags and one without. For me the greater disk usage would be preferable to running some complex function with every query.
Regex is processor expensive. You wouldn't want to run the regex for each call to the database or you would quickly bring even a moderate server to its knees with a low-med volume site.
criterion9, yes, it's work not so fast, but author of the topic didn't ask about fast solution and why did you decide that he going to run this query very often. Maybe he going to run it under admin panel sometimes?
Bookmarks