سؤال

I'm using the cakedc plugin on cakephp to implement a search on a field in the database (called Post.body). It works fine, but if the field contains html tags (like <p> or <img>, etc), the search will be performed on them as well. Is it possible to filter out / sanitize the search?

Thank you in advance

هل كانت مفيدة؟

المحلول

Should be possible, but it would be highly inefficient in a query as it would most probably make using indices impossible since you have to filter the content of every possible column before performing the actual search.

I'd suggest to store a pre-filtered version of the content in an additional column, and search on that one instead. That way you can continue using simple search conditions and the DBMS can make use of full-text indices.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top