just a quick question. I'm developping in cakePHP

I'd like to add a reference number to every entry in my Model, and for that i'd like a function, that will be executed in the Model's beforeSave() that will count the number of entries already created this month, and my ref number will then be YYYMMXXX, with XXX the number of this entry since day one of the month.

Should i place this counting function in the Controller or the Model ? I have a doubt here..

Thanks for the advice !

有帮助吗?

解决方案

It will be better to place the functon in your model because logical part of coding is done in the model.Also it will provide reusability of code.Since controller is not used for writing logic you can use model for that.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top