How to use helper function inside CakePHP model

Now, before you burn me at the stake, listen to me!

I want some keywords in the product description field to associate with other products (like links to MediaWiki), however at some point I need to make these associations and link the keywords, so I will need to search for every interspersed word that I I find in the description and create a formatted version of the description to reduce the processing of these keyword links each time the description is displayed.

For simplicity / consistency, I create all the product links using a special assistant, and all I need to do is pass the product line, and auxiliary products - the link for me with any parameters that I specify. The only thing I want to do is that I need to do this in beforeSave () so that I can fill out description_formatted.

On the negative side, beforeSave () checks the original description line, then calls a private method in the model that matches each keyword, requests db for the corresponding line ... as far as I know.

+3
source share
2 answers

? , Ajax, - , . , .

- PHP, , .

- , .

+1
+2

Source: https://habr.com/ru/post/1796536/


All Articles